Skip to content

Commit

Permalink
enable more tests #10659
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jun 19, 2018
1 parent 1ae8202 commit 45bfc0a
Showing 1 changed file with 36 additions and 47 deletions.
83 changes: 36 additions & 47 deletions src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,55 +373,44 @@ suite('ExtHostTypes', function () {

edit.set(b, [types.TextEdit.insert(new types.Position(0, 0), 'ffff')]);
assert.equal(edit.get(b).length, 1);

});

// test('WorkspaceEdit should fail when editing deleted resource', () => {
// const resource = URI.parse('file:///a.ts');

// const edit = new types.WorkspaceEdit();
// edit.deleteResource(resource);
// try {
// edit.insert(resource, new types.Position(0, 0), '');
// assert.fail(false, 'Should disallow edit of deleted resource');
// } catch {
// // expected
// }
// });

// test('WorkspaceEdit - keep order of text and file changes', function () {

// const edit = new types.WorkspaceEdit();
// edit.replace(URI.parse('foo:a'), new types.Range(1, 1, 1, 1), 'foo');
// edit.renameResource(URI.parse('foo:a'), URI.parse('foo:b'));
// edit.replace(URI.parse('foo:a'), new types.Range(2, 1, 2, 1), 'bar');
// edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');

// const all = edit.allEntries();
// assert.equal(all.length, 3);

// function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, URI] {
// const [f, s] = thing;
// return URI.isUri(f) && URI.isUri(s);
// }

// function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, types.TextEdit[]] {
// const [f, s] = thing;
// return URI.isUri(f) && Array.isArray(s);
// }

// const [first, second, third] = all;
// assert.equal(first[0].toString(), 'foo:a');
// assert.ok(!isFileChange(first));
// assert.ok(isTextChange(first) && first[1].length === 2);

// assert.equal(second[0].toString(), 'foo:a');
// assert.ok(isFileChange(second));

// assert.equal(third[0].toString(), 'foo:b');
// assert.ok(!isFileChange(third));
// assert.ok(isTextChange(third) && third[1].length === 1);
// });
test('WorkspaceEdit - keep order of text and file changes', function () {

const edit = new types.WorkspaceEdit();
edit.replace(URI.parse('foo:a'), new types.Range(1, 1, 1, 1), 'foo');
edit.renameFile(URI.parse('foo:a'), URI.parse('foo:b'));
edit.replace(URI.parse('foo:a'), new types.Range(2, 1, 2, 1), 'bar');
edit.replace(URI.parse('foo:b'), new types.Range(3, 1, 3, 1), 'bazz');

const all = edit.allEntries();
assert.equal(all.length, 4);

function isFileChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, URI] {
const [f, s] = thing;
return URI.isUri(f) && URI.isUri(s);
}

function isTextChange(thing: [URI, types.TextEdit[]] | [URI, URI]): thing is [URI, types.TextEdit[]] {
const [f, s] = thing;
return URI.isUri(f) && Array.isArray(s);
}

const [first, second, third, fourth] = all;
assert.equal(first[0].toString(), 'foo:a');
assert.ok(!isFileChange(first));
assert.ok(isTextChange(first) && first[1].length === 1);

assert.equal(second[0].toString(), 'foo:a');
assert.ok(isFileChange(second));

assert.equal(third[0].toString(), 'foo:a');
assert.ok(isTextChange(third) && third[1].length === 1);

assert.equal(fourth[0].toString(), 'foo:b');
assert.ok(!isFileChange(fourth));
assert.ok(isTextChange(fourth) && fourth[1].length === 1);
});

test('DocumentLink', function () {
assert.throws(() => new types.DocumentLink(null, null));
Expand Down

0 comments on commit 45bfc0a

Please sign in to comment.