未验证 提交 0199bf71 编写于 作者: A Alex Dima

Add more tests

上级 38233bcb
......@@ -328,6 +328,36 @@ suite('ModelService', () => {
assert.equal(model2.getValue(), 'text');
});
}
test('does not maintain undo for same resource and different content', () => {
const resource = URI.parse('file://test.txt');
// create a model
const model1 = modelService.createModel('text', null, resource);
// make an edit
model1.pushEditOperations(null, [{ range: new Range(1, 5, 1, 5), text: '1' }], () => [new Selection(1, 5, 1, 5)]);
assert.equal(model1.getValue(), 'text1');
// dispose it
modelService.destroyModel(resource);
// create a new model with the same content
const model2 = modelService.createModel('text2', null, resource);
// undo
model2.undo();
assert.equal(model2.getValue(), 'text2');
});
test('setValue should clear undo stack', () => {
const resource = URI.parse('file://test.txt');
const model = modelService.createModel('text', null, resource);
model.pushEditOperations(null, [{ range: new Range(1, 5, 1, 5), text: '1' }], () => [new Selection(1, 5, 1, 5)]);
assert.equal(model.getValue(), 'text1');
model.setValue('text2');
model.undo();
assert.equal(model.getValue(), 'text2');
});
});
function assertComputeEdits(lines1: string[], lines2: string[]): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册