diff --git a/src/vs/editor/contrib/suggest/test/suggest.test.ts b/src/vs/editor/contrib/suggest/test/suggest.test.ts index b0f1d6a2ef70436132a86fa3c635202316d42979..f3dd938ceb77357a3b62266ab4f69a8d0dfd5687 100644 --- a/src/vs/editor/contrib/suggest/test/suggest.test.ts +++ b/src/vs/editor/contrib/suggest/test/suggest.test.ts @@ -46,38 +46,34 @@ suite('Suggest', function () { model.dispose(); }); - test('sort - snippet inline', function () { - return provideSuggestionItems(model, new Position(1, 1), 'inline').then(items => { - assert.equal(items.length, 3); - assert.equal(items[0].suggestion.label, 'aaa'); - assert.equal(items[1].suggestion.label, 'fff'); - assert.equal(items[2].suggestion.label, 'zzz'); - }); + test('sort - snippet inline', async function () { + const items = await provideSuggestionItems(model, new Position(1, 1), 'inline'); + assert.equal(items.length, 3); + assert.equal(items[0].suggestion.label, 'aaa'); + assert.equal(items[1].suggestion.label, 'fff'); + assert.equal(items[2].suggestion.label, 'zzz'); }); - test('sort - snippet top', function () { - return provideSuggestionItems(model, new Position(1, 1), 'top').then(items => { - assert.equal(items.length, 3); - assert.equal(items[0].suggestion.label, 'aaa'); - assert.equal(items[1].suggestion.label, 'zzz'); - assert.equal(items[2].suggestion.label, 'fff'); - }); + test('sort - snippet top', async function () { + const items = await provideSuggestionItems(model, new Position(1, 1), 'top'); + assert.equal(items.length, 3); + assert.equal(items[0].suggestion.label, 'aaa'); + assert.equal(items[1].suggestion.label, 'zzz'); + assert.equal(items[2].suggestion.label, 'fff'); }); - test('sort - snippet bottom', function () { - return provideSuggestionItems(model, new Position(1, 1), 'bottom').then(items => { - assert.equal(items.length, 3); - assert.equal(items[0].suggestion.label, 'fff'); - assert.equal(items[1].suggestion.label, 'aaa'); - assert.equal(items[2].suggestion.label, 'zzz'); - }); + test('sort - snippet bottom', async function () { + const items = await provideSuggestionItems(model, new Position(1, 1), 'bottom'); + assert.equal(items.length, 3); + assert.equal(items[0].suggestion.label, 'fff'); + assert.equal(items[1].suggestion.label, 'aaa'); + assert.equal(items[2].suggestion.label, 'zzz'); }); - test('sort - snippet none', function () { - return provideSuggestionItems(model, new Position(1, 1), 'none').then(items => { - assert.equal(items.length, 1); - assert.equal(items[0].suggestion.label, 'fff'); - }); + test('sort - snippet none', async function () { + const items = await provideSuggestionItems(model, new Position(1, 1), 'none'); + assert.equal(items.length, 1); + assert.equal(items[0].suggestion.label, 'fff'); }); test('only from', function () { diff --git a/src/vs/platform/configuration/test/node/configurationService.test.ts b/src/vs/platform/configuration/test/node/configurationService.test.ts index 8a76f8abf71f94497d08bc6007f26535fb50e619..d7c7520d878abdc1cf3be1b63813af373a4b2c5e 100644 --- a/src/vs/platform/configuration/test/node/configurationService.test.ts +++ b/src/vs/platform/configuration/test/node/configurationService.test.ts @@ -28,53 +28,57 @@ class SettingsTestEnvironmentService extends EnvironmentService { suite('ConfigurationService - Node', () => { - test('simple', () => { - return testFile('config', 'config.json').then(res => { - fs.writeFileSync(res.testFile, '{ "foo": "bar" }'); + test('simple', async () => { + const res = await testFile('config', 'config.json'); + fs.writeFileSync(res.testFile, '{ "foo": "bar" }'); - const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); - - const config = service.getValue<{ foo: string }>(); - assert.ok(config); - assert.equal(config.foo, 'bar'); + const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); + const config = service.getValue<{ + foo: string; + }>(); - service.dispose(); + assert.ok(config); + assert.equal(config.foo, 'bar'); + service.dispose(); - return res.cleanUp(); - }); + return res.cleanUp(); }); - test('config gets flattened', () => { - return testFile('config', 'config.json').then(res => { - fs.writeFileSync(res.testFile, '{ "testworkbench.editor.tabs": true }'); + test('config gets flattened', async () => { + const res = await testFile('config', 'config.json'); - const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); + fs.writeFileSync(res.testFile, '{ "testworkbench.editor.tabs": true }'); - const config = service.getValue<{ testworkbench: { editor: { tabs: boolean } } }>(); - assert.ok(config); - assert.ok(config.testworkbench); - assert.ok(config.testworkbench.editor); - assert.equal(config.testworkbench.editor.tabs, true); - - service.dispose(); + const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); + const config = service.getValue<{ + testworkbench: { + editor: { + tabs: boolean; + }; + }; + }>(); + assert.ok(config); + assert.ok(config.testworkbench); + assert.ok(config.testworkbench.editor); + assert.equal(config.testworkbench.editor.tabs, true); - return res.cleanUp(); - }); + service.dispose(); + return res.cleanUp(); }); - test('error case does not explode', () => { - return testFile('config', 'config.json').then(res => { - fs.writeFileSync(res.testFile, ',,,,'); + test('error case does not explode', async () => { + const res = await testFile('config', 'config.json'); - const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); + fs.writeFileSync(res.testFile, ',,,,'); - const config = service.getValue<{ foo: string }>(); - assert.ok(config); - - service.dispose(); + const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); + const config = service.getValue<{ + foo: string; + }>(); + assert.ok(config); - return res.cleanUp(); - }); + service.dispose(); + return res.cleanUp(); }); test('missing file does not explode', () => { @@ -91,34 +95,36 @@ suite('ConfigurationService - Node', () => { service.dispose(); }); - test('reloadConfiguration', () => { - return testFile('config', 'config.json').then(res => { - fs.writeFileSync(res.testFile, '{ "foo": "bar" }'); - - const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); - - let config = service.getValue<{ foo: string }>(); - assert.ok(config); - assert.equal(config.foo, 'bar'); + test('reloadConfiguration', async () => { + const res = await testFile('config', 'config.json'); - fs.writeFileSync(res.testFile, '{ "foo": "changed" }'); + fs.writeFileSync(res.testFile, '{ "foo": "bar" }'); - // still outdated - config = service.getValue<{ foo: string }>(); - assert.ok(config); - assert.equal(config.foo, 'bar'); + const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); + let config = service.getValue<{ + foo: string; + }>(); + assert.ok(config); + assert.equal(config.foo, 'bar'); + fs.writeFileSync(res.testFile, '{ "foo": "changed" }'); - // force a reload to get latest - return service.reloadConfiguration().then(() => { - config = service.getValue<{ foo: string }>(); - assert.ok(config); - assert.equal(config.foo, 'changed'); + // still outdated + config = service.getValue<{ + foo: string; + }>(); + assert.ok(config); + assert.equal(config.foo, 'bar'); - service.dispose(); + // force a reload to get latest + await service.reloadConfiguration(); + config = service.getValue<{ + foo: string; + }>(); + assert.ok(config); + assert.equal(config.foo, 'changed'); - return res.cleanUp(); - }); - }); + service.dispose(); + return res.cleanUp(); }); test('model defaults', () => { @@ -148,7 +154,7 @@ suite('ConfigurationService - Node', () => { assert.ok(setting); assert.equal(setting.configuration.service.testSetting, 'isSet'); - return testFile('config', 'config.json').then(res => { + return testFile('config', 'config.json').then(async res => { fs.writeFileSync(res.testFile, '{ "testworkbench.editor.tabs": true }'); const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, res.testFile)); @@ -160,21 +166,17 @@ suite('ConfigurationService - Node', () => { fs.writeFileSync(res.testFile, '{ "configuration.service.testSetting": "isChanged" }'); - return service.reloadConfiguration().then(() => { - let setting = service.getValue(); - - assert.ok(setting); - assert.equal(setting.configuration.service.testSetting, 'isChanged'); - - service.dispose(); - serviceWithoutFile.dispose(); - - return res.cleanUp(); - }); + await service.reloadConfiguration(); + let setting_1 = service.getValue(); + assert.ok(setting_1); + assert.equal(setting_1.configuration.service.testSetting, 'isChanged'); + service.dispose(); + serviceWithoutFile.dispose(); + return res.cleanUp(); }); }); - test('lookup', () => { + test('lookup', async () => { const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); configurationRegistry.registerConfiguration({ 'id': '_test', @@ -187,35 +189,31 @@ suite('ConfigurationService - Node', () => { } }); - return testFile('config', 'config.json').then(r => { - const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, r.testFile)); - - let res = service.inspect('something.missing'); - assert.strictEqual(res.value, void 0); - assert.strictEqual(res.default, void 0); - assert.strictEqual(res.user, void 0); - - res = service.inspect('lookup.service.testSetting'); - assert.strictEqual(res.default, 'isSet'); - assert.strictEqual(res.value, 'isSet'); - assert.strictEqual(res.user, void 0); + const r = await testFile('config', 'config.json'); + const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, r.testFile)); + let res = service.inspect('something.missing'); + assert.strictEqual(res.value, void 0); + assert.strictEqual(res.default, void 0); + assert.strictEqual(res.user, void 0); - fs.writeFileSync(r.testFile, '{ "lookup.service.testSetting": "bar" }'); + res = service.inspect('lookup.service.testSetting'); + assert.strictEqual(res.default, 'isSet'); + assert.strictEqual(res.value, 'isSet'); + assert.strictEqual(res.user, void 0); - return service.reloadConfiguration().then(() => { - res = service.inspect('lookup.service.testSetting'); - assert.strictEqual(res.default, 'isSet'); - assert.strictEqual(res.user, 'bar'); - assert.strictEqual(res.value, 'bar'); + fs.writeFileSync(r.testFile, '{ "lookup.service.testSetting": "bar" }'); - service.dispose(); + await service.reloadConfiguration(); + res = service.inspect('lookup.service.testSetting'); + assert.strictEqual(res.default, 'isSet'); + assert.strictEqual(res.user, 'bar'); + assert.strictEqual(res.value, 'bar'); - return r.cleanUp(); - }); - }); + service.dispose(); + return r.cleanUp(); }); - test('lookup with null', () => { + test('lookup with null', async () => { const configurationRegistry = Registry.as(ConfigurationExtensions.Configuration); configurationRegistry.registerConfiguration({ 'id': '_testNull', @@ -227,26 +225,23 @@ suite('ConfigurationService - Node', () => { } }); - return testFile('config', 'config.json').then(r => { - const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, r.testFile)); - - let res = service.inspect('lookup.service.testNullSetting'); - assert.strictEqual(res.default, null); - assert.strictEqual(res.value, null); - assert.strictEqual(res.user, void 0); + const r = await testFile('config', 'config.json'); + const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, r.testFile)); + let res = service.inspect('lookup.service.testNullSetting'); + assert.strictEqual(res.default, null); + assert.strictEqual(res.value, null); + assert.strictEqual(res.user, void 0); - fs.writeFileSync(r.testFile, '{ "lookup.service.testNullSetting": null }'); + fs.writeFileSync(r.testFile, '{ "lookup.service.testNullSetting": null }'); - return service.reloadConfiguration().then(() => { - res = service.inspect('lookup.service.testNullSetting'); - assert.strictEqual(res.default, null); - assert.strictEqual(res.value, null); - assert.strictEqual(res.user, null); + await service.reloadConfiguration(); - service.dispose(); + res = service.inspect('lookup.service.testNullSetting'); + assert.strictEqual(res.default, null); + assert.strictEqual(res.value, null); + assert.strictEqual(res.user, null); - return r.cleanUp(); - }); - }); + service.dispose(); + return r.cleanUp(); }); }); diff --git a/src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts b/src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts index 7150dca8323a6148a1e3fa2f851fabb2006eaff3..2f4e79f208a8d12a3fe923391153a5ee6c741a2c 100644 --- a/src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts +++ b/src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts @@ -12,10 +12,9 @@ import { ScanCodeBinding, ScanCode } from 'vs/base/common/scanCode'; const WRITE_FILE_IF_DIFFERENT = false; -function createKeyboardMapper(isUSStandard: boolean, file: string): TPromise { - return readRawMapping(file).then((rawMappings) => { - return new WindowsKeyboardMapper(isUSStandard, rawMappings); - }); +async function createKeyboardMapper(isUSStandard: boolean, file: string): TPromise { + const rawMappings = await readRawMapping(file); + return new WindowsKeyboardMapper(isUSStandard, rawMappings); } function _assertResolveKeybinding(mapper: WindowsKeyboardMapper, k: number, expected: IResolvedKeybinding[]): void { @@ -26,10 +25,8 @@ suite('keyboardMapper - WINDOWS de_ch', () => { let mapper: WindowsKeyboardMapper; - suiteSetup(() => { - return createKeyboardMapper(false, 'win_de_ch').then((_mapper) => { - mapper = _mapper; - }); + suiteSetup(async () => { + mapper = await createKeyboardMapper(false, 'win_de_ch'); }); test('mapping', () => { @@ -318,10 +315,8 @@ suite('keyboardMapper - WINDOWS en_us', () => { let mapper: WindowsKeyboardMapper; - suiteSetup(() => { - return createKeyboardMapper(true, 'win_en_us').then((_mapper) => { - mapper = _mapper; - }); + suiteSetup(async () => { + mapper = await createKeyboardMapper(true, 'win_en_us'); }); test('mapping', () => { @@ -406,10 +401,8 @@ suite('keyboardMapper - WINDOWS por_ptb', () => { let mapper: WindowsKeyboardMapper; - suiteSetup(() => { - return createKeyboardMapper(false, 'win_por_ptb').then((_mapper) => { - mapper = _mapper; - }); + suiteSetup(async () => { + mapper = await createKeyboardMapper(false, 'win_por_ptb'); }); test('mapping', () => { @@ -467,10 +460,8 @@ suite('keyboardMapper - WINDOWS ru', () => { let mapper: WindowsKeyboardMapper; - suiteSetup(() => { - return createKeyboardMapper(false, 'win_ru').then((_mapper) => { - mapper = _mapper; - }); + suiteSetup(async () => { + mapper = await createKeyboardMapper(false, 'win_ru'); }); test('mapping', () => { diff --git a/src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts b/src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts index e607fdd1b5fbf2e6fc10b70fb5bcae074dcbca48..8bdb73811c08d4bb49ac6e9e0849c8eed5cc4bdc 100644 --- a/src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts +++ b/src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts @@ -51,31 +51,29 @@ suite('Keybindings Editor Model test', () => { CommandsRegistry.registerCommand('command_without_keybinding', () => { }); }); - test('fetch returns default keybindings', () => { + test('fetch returns default keybindings', async () => { const expected = prepareKeybindingService( aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape } }), aResolvedKeybindingItem({ command: 'b' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }) ); - return testObject.resolve({}).then(() => { - const actuals = asResolvedKeybindingItems(testObject.fetch('')); - assertKeybindingItems(actuals, expected); - }); + await testObject.resolve({}); + const actuals = asResolvedKeybindingItems(testObject.fetch('')); + assertKeybindingItems(actuals, expected); }); - test('fetch returns default keybindings at the top', () => { + test('fetch returns default keybindings at the top', async () => { const expected = prepareKeybindingService( aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape } }), aResolvedKeybindingItem({ command: 'b' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }) ); - return testObject.resolve({}).then(() => { - const actuals = asResolvedKeybindingItems(testObject.fetch('').slice(0, 2), true); - assertKeybindingItems(actuals, expected); - }); + await testObject.resolve({}); + const actuals = asResolvedKeybindingItems(testObject.fetch('').slice(0, 2), true); + assertKeybindingItems(actuals, expected); }); - test('fetch returns default keybindings sorted by command id', () => { + test('fetch returns default keybindings sorted by command id', async () => { const keybindings = prepareKeybindingService( aResolvedKeybindingItem({ command: 'b' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape } }), aResolvedKeybindingItem({ command: 'c' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }), @@ -83,13 +81,12 @@ suite('Keybindings Editor Model test', () => { ); const expected = [keybindings[2], keybindings[0], keybindings[1]]; - return testObject.resolve({}).then(() => { - const actuals = asResolvedKeybindingItems(testObject.fetch('')); - assertKeybindingItems(actuals, expected); - }); + await testObject.resolve({}); + const actuals = asResolvedKeybindingItems(testObject.fetch('')); + assertKeybindingItems(actuals, expected); }); - test('fetch returns user keybinding first if default and user has same id', () => { + test('fetch returns user keybinding first if default and user has same id', async () => { const sameId = 'b' + uuid.generateUuid(); const keybindings = prepareKeybindingService( aResolvedKeybindingItem({ command: sameId, firstPart: { keyCode: KeyCode.Escape } }), @@ -97,13 +94,12 @@ suite('Keybindings Editor Model test', () => { ); const expected = [keybindings[1], keybindings[0]]; - return testObject.resolve({}).then(() => { - const actuals = asResolvedKeybindingItems(testObject.fetch('')); - assertKeybindingItems(actuals, expected); - }); + await testObject.resolve({}); + const actuals = asResolvedKeybindingItems(testObject.fetch('')); + assertKeybindingItems(actuals, expected); }); - test('fetch returns keybinding with titles first', () => { + test('fetch returns keybinding with titles first', async () => { const keybindings = prepareKeybindingService( aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape } }), aResolvedKeybindingItem({ command: 'b' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }), @@ -118,13 +114,12 @@ suite('Keybindings Editor Model test', () => { instantiationService.stub(IKeybindingService, 'getKeybindings', () => keybindings); instantiationService.stub(IKeybindingService, 'getDefaultKeybindings', () => keybindings); - return testObject.resolve({}).then(() => { - const actuals = asResolvedKeybindingItems(testObject.fetch('')); - assertKeybindingItems(actuals, expected); - }); + await testObject.resolve({}); + const actuals = asResolvedKeybindingItems(testObject.fetch('')); + assertKeybindingItems(actuals, expected); }); - test('fetch returns keybinding with user first if title and id matches', () => { + test('fetch returns keybinding with user first if title and id matches', async () => { const sameId = 'b' + uuid.generateUuid(); const keybindings = prepareKeybindingService( aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape } }), @@ -137,465 +132,429 @@ suite('Keybindings Editor Model test', () => { registerCommandWithTitle(keybindings[3].command, 'Same Title'); const expected = [keybindings[3], keybindings[1], keybindings[0], keybindings[2]]; - return testObject.resolve({}).then(() => { - const actuals = asResolvedKeybindingItems(testObject.fetch('')); - assertKeybindingItems(actuals, expected); - }); + await testObject.resolve({}); + const actuals = asResolvedKeybindingItems(testObject.fetch('')); + assertKeybindingItems(actuals, expected); }); - test('fetch returns default keybindings sorted by precedence', () => { + test('fetch returns default keybindings sorted by precedence', async () => { const expected = prepareKeybindingService( aResolvedKeybindingItem({ command: 'b' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape } }), aResolvedKeybindingItem({ command: 'c' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }), aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Backspace } }) ); - return testObject.resolve({}).then(() => { - const actuals = asResolvedKeybindingItems(testObject.fetch('', true)); - assertKeybindingItems(actuals, expected); - }); + await testObject.resolve({}); + const actuals = asResolvedKeybindingItems(testObject.fetch('', true)); + assertKeybindingItems(actuals, expected); }); - test('convert keybinding without title to entry', () => { + test('convert keybinding without title to entry', async () => { const expected = aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2' }); prepareKeybindingService(expected); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('')[0]; - assert.equal(actual.keybindingItem.command, expected.command); - assert.equal(actual.keybindingItem.commandLabel, ''); - assert.equal(actual.keybindingItem.commandDefaultLabel, null); - assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding.getAriaLabel()); - assert.equal(actual.keybindingItem.when, expected.when.serialize()); - }); + await testObject.resolve({}); + const actual = testObject.fetch('')[0]; + assert.equal(actual.keybindingItem.command, expected.command); + assert.equal(actual.keybindingItem.commandLabel, ''); + assert.equal(actual.keybindingItem.commandDefaultLabel, null); + assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding.getAriaLabel()); + assert.equal(actual.keybindingItem.when, expected.when.serialize()); }); - test('convert keybinding with title to entry', () => { + test('convert keybinding with title to entry', async () => { const expected = aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2' }); prepareKeybindingService(expected); registerCommandWithTitle(expected.command, 'Some Title'); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('')[0]; - assert.equal(actual.keybindingItem.command, expected.command); - assert.equal(actual.keybindingItem.commandLabel, 'Some Title'); - assert.equal(actual.keybindingItem.commandDefaultLabel, null); - assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding.getAriaLabel()); - assert.equal(actual.keybindingItem.when, expected.when.serialize()); - }); + await testObject.resolve({}); + const actual = testObject.fetch('')[0]; + assert.equal(actual.keybindingItem.command, expected.command); + assert.equal(actual.keybindingItem.commandLabel, 'Some Title'); + assert.equal(actual.keybindingItem.commandDefaultLabel, null); + assert.equal(actual.keybindingItem.keybinding.getAriaLabel(), expected.resolvedKeybinding.getAriaLabel()); + assert.equal(actual.keybindingItem.when, expected.when.serialize()); }); - test('convert without title and binding to entry', () => { + test('convert without title and binding to entry', async () => { CommandsRegistry.registerCommand('command_without_keybinding', () => { }); prepareKeybindingService(); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('').filter(element => element.keybindingItem.command === 'command_without_keybinding')[0]; - assert.equal(actual.keybindingItem.command, 'command_without_keybinding'); - assert.equal(actual.keybindingItem.commandLabel, ''); - assert.equal(actual.keybindingItem.commandDefaultLabel, null); - assert.equal(actual.keybindingItem.keybinding, null); - assert.equal(actual.keybindingItem.when, ''); - }); + await testObject.resolve({}); + const actual = testObject.fetch('').filter(element => element.keybindingItem.command === 'command_without_keybinding')[0]; + assert.equal(actual.keybindingItem.command, 'command_without_keybinding'); + assert.equal(actual.keybindingItem.commandLabel, ''); + assert.equal(actual.keybindingItem.commandDefaultLabel, null); + assert.equal(actual.keybindingItem.keybinding, null); + assert.equal(actual.keybindingItem.when, ''); }); - test('convert with title and wihtout binding to entry', () => { + test('convert with title and wihtout binding to entry', async () => { const id = 'a' + uuid.generateUuid(); registerCommandWithTitle(id, 'some title'); prepareKeybindingService(); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('').filter(element => element.keybindingItem.command === id)[0]; - assert.equal(actual.keybindingItem.command, id); - assert.equal(actual.keybindingItem.commandLabel, 'some title'); - assert.equal(actual.keybindingItem.commandDefaultLabel, null); - assert.equal(actual.keybindingItem.keybinding, null); - assert.equal(actual.keybindingItem.when, ''); - }); + await testObject.resolve({}); + const actual = testObject.fetch('').filter(element => element.keybindingItem.command === id)[0]; + assert.equal(actual.keybindingItem.command, id); + assert.equal(actual.keybindingItem.commandLabel, 'some title'); + assert.equal(actual.keybindingItem.commandDefaultLabel, null); + assert.equal(actual.keybindingItem.keybinding, null); + assert.equal(actual.keybindingItem.when, ''); }); - test('filter by command id', () => { + test('filter by command id', async () => { const id = 'workbench.action.increaseViewSize'; registerCommandWithTitle(id, 'some title'); prepareKeybindingService(); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('workbench action view size').filter(element => element.keybindingItem.command === id)[0]; - assert.ok(actual); - }); + await testObject.resolve({}); + const actual = testObject.fetch('workbench action view size').filter(element => element.keybindingItem.command === id)[0]; + assert.ok(actual); }); - test('filter by command title', () => { + test('filter by command title', async () => { const id = 'a' + uuid.generateUuid(); registerCommandWithTitle(id, 'Increase view size'); prepareKeybindingService(); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('increase size').filter(element => element.keybindingItem.command === id)[0]; - assert.ok(actual); - }); + await testObject.resolve({}); + const actual = testObject.fetch('increase size').filter(element => element.keybindingItem.command === id)[0]; + assert.ok(actual); }); - test('filter by default source', () => { + test('filter by default source', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2' }); prepareKeybindingService(expected); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('default').filter(element => element.keybindingItem.command === command)[0]; - assert.ok(actual); - }); + await testObject.resolve({}); + const actual = testObject.fetch('default').filter(element => element.keybindingItem.command === command)[0]; + assert.ok(actual); }); - test('filter by user source', () => { + test('filter by user source', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2', isDefault: false }); prepareKeybindingService(expected); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('user').filter(element => element.keybindingItem.command === command)[0]; - assert.ok(actual); - }); + await testObject.resolve({}); + const actual = testObject.fetch('user').filter(element => element.keybindingItem.command === command)[0]; + assert.ok(actual); }); - test('filter by default source with "@source: " prefix', () => { + test('filter by default source with "@source: " prefix', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2', isDefault: true }); prepareKeybindingService(expected); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('@source: default').filter(element => element.keybindingItem.command === command)[0]; - assert.ok(actual); - }); + await testObject.resolve({}); + const actual = testObject.fetch('@source: default').filter(element => element.keybindingItem.command === command)[0]; + assert.ok(actual); }); - test('filter by user source with "@source: " prefix', () => { + test('filter by user source with "@source: " prefix', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2', isDefault: false }); prepareKeybindingService(expected); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('@source: user').filter(element => element.keybindingItem.command === command)[0]; - assert.ok(actual); - }); + await testObject.resolve({}); + const actual = testObject.fetch('@source: user').filter(element => element.keybindingItem.command === command)[0]; + assert.ok(actual); }); - test('filter by when context', () => { + test('filter by when context', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('when context').filter(element => element.keybindingItem.command === command)[0]; - assert.ok(actual); - }); + await testObject.resolve({}); + const actual = testObject.fetch('when context').filter(element => element.keybindingItem.command === command)[0]; + assert.ok(actual); }); - test('filter by cmd key', () => { + test('filter by cmd key', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('cmd').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('cmd').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by meta key', () => { + test('filter by meta key', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('meta').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('meta').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by command key', () => { + test('filter by command key', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('command').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('command').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by windows key', () => { + test('filter by windows key', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Windows); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('windows').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('windows').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by alt key', () => { + test('filter by alt key', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('alt').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('alt').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by option key', () => { + test('filter by option key', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('option').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('option').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by ctrl key', () => { + test('filter by ctrl key', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('ctrl').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('ctrl').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by control key', () => { + test('filter by control key', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('control').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('control').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by shift key', () => { + test('filter by shift key', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('shift').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('shift').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by arrow', () => { + test('filter by arrow', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { shiftKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('arrow').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('arrow').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by modifier and key', () => { + test('filter by modifier and key', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('alt right').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('alt right').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by key and modifier', () => { + test('filter by key and modifier', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('right alt').filter(element => element.keybindingItem.command === command); - assert.equal(0, actual.length); - }); + await testObject.resolve({}); + const actual = testObject.fetch('right alt').filter(element => element.keybindingItem.command === command); + assert.equal(0, actual.length); }); - test('filter by modifiers and key', () => { + test('filter by modifiers and key', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { altKey: true, metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('alt cmd esc').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, metaKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('alt cmd esc').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, metaKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by modifiers in random order and key', () => { + test('filter by modifiers in random order and key', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter by first part', () => { + test('filter by first part', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.Delete }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter matches in chord part', () => { + test('filter matches in chord part', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.Delete }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('cmd del').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true }); - }); + await testObject.resolve({}); + const actual = testObject.fetch('cmd del').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true }); }); - test('filter matches first part and in chord part', () => { + test('filter matches first part and in chord part', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.Delete }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.UpArrow }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('cmd shift esc del').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true }); - }); + await testObject.resolve({}); + const actual = testObject.fetch('cmd shift esc del').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true }); }); - test('filter exact matches', () => { + test('filter exact matches', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('"ctrl c"').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('"ctrl c"').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter exact matches with first and chord part', () => { + test('filter exact matches with first and chord part', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('"shift meta escape ctrl c"').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, { ctrlKey: true, keyCode: true }); - }); + await testObject.resolve({}); + const actual = testObject.fetch('"shift meta escape ctrl c"').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, { ctrlKey: true, keyCode: true }); }); - test('filter exact matches with first and chord part no results', () => { + test('filter exact matches with first and chord part no results', async () => { testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh); const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.Delete, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.UpArrow }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('"cmd shift esc del"').filter(element => element.keybindingItem.command === command); - assert.equal(0, actual.length); - }); + await testObject.resolve({}); + const actual = testObject.fetch('"cmd shift esc del"').filter(element => element.keybindingItem.command === command); + assert.equal(0, actual.length); }); - test('filter matches with + separator', () => { + test('filter matches with + separator', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('"control+c"').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); - }); + await testObject.resolve({}); + const actual = testObject.fetch('"control+c"').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, {}); }); - test('filter matches with + separator in first and chord parts', () => { + test('filter matches with + separator in first and chord parts', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('"shift+meta+escape ctrl+c"').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); - assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true, ctrlKey: true }); - }); + await testObject.resolve({}); + const actual = testObject.fetch('"shift+meta+escape ctrl+c"').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); + assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); + assert.deepEqual(actual[0].keybindingMatches.chordPart, { keyCode: true, ctrlKey: true }); }); - test('filter exact matches with space #32993', () => { + test('filter exact matches with space #32993', async () => { const command = 'a' + uuid.generateUuid(); const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Space, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Backspace, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve({}).then(() => { - const actual = testObject.fetch('"ctrl+space"').filter(element => element.keybindingItem.command === command); - assert.equal(1, actual.length); - }); + await testObject.resolve({}); + const actual = testObject.fetch('"ctrl+space"').filter(element => element.keybindingItem.command === command); + assert.equal(1, actual.length); }); function prepareKeybindingService(...keybindingItems: ResolvedKeybindingItem[]): ResolvedKeybindingItem[] { diff --git a/src/vs/workbench/services/search/test/node/searchService.test.ts b/src/vs/workbench/services/search/test/node/searchService.test.ts index e056c20ca43fc28602f03ff711858aa7dadc49d4..be347aa6c24c30d8d75b93415f0c7f0980e8927c 100644 --- a/src/vs/workbench/services/search/test/node/searchService.test.ts +++ b/src/vs/workbench/services/search/test/node/searchService.test.ts @@ -91,7 +91,7 @@ suite('SearchService', () => { path: path.normalize('/some/where') }; - test('Individual results', function () { + test('Individual results', async function () { this.timeout(testTimeout); let i = 5; const Engine = TestSearchEngine.bind(null, () => i-- && rawMatch); @@ -107,11 +107,11 @@ suite('SearchService', () => { } }; - return service.doFileSearch(Engine, rawSearch, cb) - .then(() => assert.strictEqual(results, 5)); + await service.doFileSearch(Engine, rawSearch, cb); + return assert.strictEqual(results, 5); }); - test('Batch results', function () { + test('Batch results', async function () { this.timeout(testTimeout); let i = 25; const Engine = TestSearchEngine.bind(null, () => i-- && rawMatch); @@ -129,12 +129,11 @@ suite('SearchService', () => { } }; - return service.doFileSearch(Engine, rawSearch, cb, undefined, 10).then(() => { - assert.deepStrictEqual(results, [10, 10, 5]); - }); + await service.doFileSearch(Engine, rawSearch, cb, undefined, 10); + assert.deepStrictEqual(results, [10, 10, 5]); }); - test('Collect batched results', function () { + test('Collect batched results', async function () { this.timeout(testTimeout); const uriPath = '/some/where'; let i = 25; @@ -163,14 +162,12 @@ suite('SearchService', () => { progressResults.push(match); }; - return DiskSearch.collectResultsFromEvent(fileSearch(rawSearch, 10), onProgress) - .then(result => { - assert.strictEqual(result.results.length, 25, 'Result'); - assert.strictEqual(progressResults.length, 25, 'Progress'); - }); + const result_2 = await DiskSearch.collectResultsFromEvent(fileSearch(rawSearch, 10), onProgress); + assert.strictEqual(result_2.results.length, 25, 'Result'); + assert.strictEqual(progressResults.length, 25, 'Progress'); }); - test('Multi-root with include pattern and maxResults', function () { + test('Multi-root with include pattern and maxResults', async function () { this.timeout(testTimeout); const service = new RawSearchService(); @@ -183,13 +180,11 @@ suite('SearchService', () => { }, }; - return DiskSearch.collectResultsFromEvent(service.fileSearch(query)) - .then(result => { - assert.strictEqual(result.results.length, 1, 'Result'); - }); + const result = await DiskSearch.collectResultsFromEvent(service.fileSearch(query)); + assert.strictEqual(result.results.length, 1, 'Result'); }); - test('Multi-root with include pattern and exists', function () { + test('Multi-root with include pattern and exists', async function () { this.timeout(testTimeout); const service = new RawSearchService(); @@ -202,14 +197,12 @@ suite('SearchService', () => { }, }; - return DiskSearch.collectResultsFromEvent(service.fileSearch(query)) - .then(result => { - assert.strictEqual(result.results.length, 0, 'Result'); - assert.ok(result.limitHit); - }); + const result = await DiskSearch.collectResultsFromEvent(service.fileSearch(query)); + assert.strictEqual(result.results.length, 0, 'Result'); + assert.ok(result.limitHit); }); - test('Sorted results', function () { + test('Sorted results', async function () { this.timeout(testTimeout); const paths = ['bab', 'bbc', 'abb']; const matches: IRawFileMatch[] = paths.map(relativePath => ({ @@ -230,18 +223,17 @@ suite('SearchService', () => { } }; - return service.doFileSearch(Engine, { + await service.doFileSearch(Engine, { folderQueries: TEST_FOLDER_QUERIES, filePattern: 'bb', sortByScore: true, maxResults: 2 - }, cb, undefined, 1).then(() => { - assert.notStrictEqual(typeof TestSearchEngine.last.config.maxResults, 'number'); - assert.deepStrictEqual(results, [path.normalize('/some/where/bbc'), path.normalize('/some/where/bab')]); - }); + }, cb, undefined, 1); + assert.notStrictEqual(typeof TestSearchEngine.last.config.maxResults, 'number'); + assert.deepStrictEqual(results, [path.normalize('/some/where/bbc'), path.normalize('/some/where/bab')]); }); - test('Sorted result batches', function () { + test('Sorted result batches', async function () { this.timeout(testTimeout); let i = 25; const Engine = TestSearchEngine.bind(null, () => i-- && rawMatch); @@ -258,15 +250,13 @@ suite('SearchService', () => { assert.fail(JSON.stringify(value)); } }; - return service.doFileSearch(Engine, { + await service.doFileSearch(Engine, { folderQueries: TEST_FOLDER_QUERIES, filePattern: 'a', sortByScore: true, maxResults: 23 - }, cb, undefined, 10) - .then(() => { - assert.deepStrictEqual(results, [10, 10, 3]); - }); + }, cb, undefined, 10); + assert.deepStrictEqual(results, [10, 10, 3]); }); test('Cached results', function () { @@ -297,7 +287,7 @@ suite('SearchService', () => { }, cb, undefined, -1).then(complete => { assert.strictEqual((complete.stats).fromCache, false); assert.deepStrictEqual(results, [path.normalize('/some/where/bcb'), path.normalize('/some/where/bbc'), path.normalize('/some/where/aab')]); - }).then(() => { + }).then(async () => { const results = []; const cb = value => { if (Array.isArray(value)) { @@ -306,18 +296,20 @@ suite('SearchService', () => { assert.fail(JSON.stringify(value)); } }; - return service.doFileSearch(Engine, { - folderQueries: TEST_FOLDER_QUERIES, - filePattern: 'bc', - sortByScore: true, - cacheKey: 'x' - }, cb, undefined, -1).then(complete => { + try { + const complete = await service.doFileSearch(Engine, { + folderQueries: TEST_FOLDER_QUERIES, + filePattern: 'bc', + sortByScore: true, + cacheKey: 'x' + }, cb, undefined, -1); assert.ok((complete.stats).fromCache); assert.deepStrictEqual(results, [path.normalize('/some/where/bcb'), path.normalize('/some/where/bbc')]); - }, null); + } + catch (e) { } }).then(() => { return service.clearCache('x'); - }).then(() => { + }).then(async () => { matches.push({ base: path.normalize('/some/where'), relativePath: 'bc', @@ -332,15 +324,14 @@ suite('SearchService', () => { assert.fail(JSON.stringify(value)); } }; - return service.doFileSearch(Engine, { + const complete = await service.doFileSearch(Engine, { folderQueries: TEST_FOLDER_QUERIES, filePattern: 'bc', sortByScore: true, cacheKey: 'x' - }, cb, undefined, -1).then(complete => { - assert.strictEqual((complete.stats).fromCache, false); - assert.deepStrictEqual(results, [path.normalize('/some/where/bc')]); - }); + }, cb, undefined, -1); + assert.strictEqual((complete.stats).fromCache, false); + assert.deepStrictEqual(results, [path.normalize('/some/where/bc')]); }); }); });