test('convert with title and wihtout binding to entry', async () => {
		const id = 'a' + uuid.generateUuid();
		registerCommandWithTitle(id, 'some title');
		prepareKeybindingService();

		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 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 }));

		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('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');

		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());
	});
		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, '');
		});
	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 } }),
			aResolvedKeybindingItem({ command: sameId, firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }),
			aResolvedKeybindingItem({ command: 'c' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }),
			aResolvedKeybindingItem({ command: sameId, firstPart: { keyCode: KeyCode.Escape }, isDefault: false })
		);

		registerCommandWithTitle(keybindings[1].command!, 'Same Title');
		registerCommandWithTitle(keybindings[3].command!, 'Same Title');
		const expected = [keybindings[3], keybindings[1], keybindings[0], keybindings[2]];

		await testObject.resolve({});
		const actuals = asResolvedKeybindingItems(testObject.fetch(''));
		assertKeybindingItems(actuals, expected);
	});
		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());
		});
	test('filter by command title', () => {
		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);
		});
	});
	test('filter by command id', () => {
		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);
		});
	});
	test('filter by when context', () => {
		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);
		});
	});
	test('filter by key and modifier', () => {
		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);
		});
	});