From 45bfc0a21514bc799804854695d97e0267384257 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 19 Jun 2018 16:28:19 +0200 Subject: [PATCH] enable more tests #10659 --- .../electron-browser/api/extHostTypes.test.ts | 83 ++++++++----------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts index 9c868b31e5e..6a9037d6d82 100644 --- a/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts +++ b/src/vs/workbench/test/electron-browser/api/extHostTypes.test.ts @@ -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)); -- GitLab