Skip to content

Commit

Permalink
test: Refactor openRandomNote.spec.ts to use command directly
Browse files Browse the repository at this point in the history
  • Loading branch information
svsool committed Aug 6, 2020
1 parent 4cb7436 commit 236ef5e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/commands/openRandomNote.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { commands } from 'vscode';

import openRandomNote from './openRandomNote';
import {
createFile,
rndName,
Expand All @@ -18,7 +17,7 @@ describe('openRandomNote command', () => {

await Promise.all(filenames.map((filename) => createFile(filename)));

await commands.executeCommand('memo.openRandomNote');
await openRandomNote();

expect(getOpenedFilenames().some((filename) => filenames.includes(filename))).toBe(true);
});
Expand All @@ -28,9 +27,9 @@ describe('openRandomNote command', () => {

await Promise.all(filenames.map((filename) => createFile(filename)));

await commands.executeCommand('memo.openRandomNote');
await commands.executeCommand('memo.openRandomNote');
await commands.executeCommand('memo.openRandomNote');
await openRandomNote();
await openRandomNote();
await openRandomNote();

await waitForExpect(() => {
expect(getOpenedFilenames()).toEqual(expect.arrayContaining(filenames));
Expand All @@ -42,9 +41,9 @@ describe('openRandomNote command', () => {

await createFile(filename);

await commands.executeCommand('memo.openRandomNote');
await commands.executeCommand('memo.openRandomNote');
await commands.executeCommand('memo.openRandomNote');
await openRandomNote();
await openRandomNote();
await openRandomNote();

expect(getOpenedFilenames()).toContain(filename);
});
Expand Down

0 comments on commit 236ef5e

Please sign in to comment.