Skip to content

Commit

Permalink
Remove tests for recent commands
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>
  • Loading branch information
dsseng committed Apr 13, 2020
1 parent 0554e1a commit 4eed751
Showing 1 changed file with 0 additions and 63 deletions.
63 changes: 0 additions & 63 deletions packages/core/src/common/command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,69 +37,6 @@ describe('Commands', () => {
expect('abc').equals(result);
});

it('should execute a given command, and add it to recently used', async () => {
const commandId = 'stub';
const command: Command = { id: commandId };
commandRegistry.registerCommand(command, new StubCommandHandler());
await commandRegistry.executeCommand(commandId);
expect(commandRegistry.recent.length).equal(1);
});

it('should execute multiple commands, and add them to recently used in the order they were used', async () => {
const commandIds = ['a', 'b', 'c'];
const commands: Command[] = [
{ id: commandIds[0] },
{ id: commandIds[1] },
{ id: commandIds[2] },
];

// Register each command.
commands.forEach((c: Command) => {
commandRegistry.registerCommand(c, new StubCommandHandler());
});

// Execute order c, b, a.
await commandRegistry.executeCommand(commandIds[2]);
await commandRegistry.executeCommand(commandIds[1]);
await commandRegistry.executeCommand(commandIds[0]);

// Expect recently used to be a, b, c.
const result: Command[] = commandRegistry.recent;

expect(result.length).equal(3);
expect(result[0].id).equal(commandIds[0]);
expect(result[1].id).equal(commandIds[1]);
expect(result[2].id).equal(commandIds[2]);
});

it('should execute a command that\'s already been executed, and add it to the top of the most recently used', async () => {
const commandIds = ['a', 'b', 'c'];
const commands: Command[] = [
{ id: commandIds[0] },
{ id: commandIds[1] },
{ id: commandIds[2] },
];

// Register each command.
commands.forEach((c: Command) => {
commandRegistry.registerCommand(c, new StubCommandHandler());
});

// Execute order a, b, c, a.
await commandRegistry.executeCommand(commandIds[0]);
await commandRegistry.executeCommand(commandIds[1]);
await commandRegistry.executeCommand(commandIds[2]);
await commandRegistry.executeCommand(commandIds[0]);

// Expect recently used to be a, b, c.
const result: Command[] = commandRegistry.recent;

expect(result.length).equal(3);
expect(result[0].id).equal(commandIds[0]);
expect(result[1].id).equal(commandIds[2]);
expect(result[2].id).equal(commandIds[1]);
});

it('should clear the recently used command history', async () => {
const commandIds = ['a', 'b', 'c'];
const commands: Command[] = [
Expand Down

0 comments on commit 4eed751

Please sign in to comment.