Skip to content

Commit

Permalink
clean up test a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
connectdotz committed Aug 23, 2021
1 parent 44d42bf commit 978e4b7
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tests/extensionManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,11 @@ describe('ExtensionManager', () => {
});
describe('activate', () => {
let ext1, ext2;
let workspaceState;
beforeEach(() => {
workspaceState = {
get: jest.fn(),
update: jest.fn(),
const map = new Map<string, boolean>();
const workspaceState = {
get: jest.fn((key) => map.get(key)),
update: jest.fn((key: string, value: boolean) => map.set(key, value)),
};

extensionManager = createExtensionManager(['ws-1', 'ws-2'], { workspaceState });
Expand Down Expand Up @@ -624,7 +624,6 @@ describe('ExtensionManager', () => {
describe('can show test explore information once per workspace', () => {
beforeEach(() => {
(vscode.window.activeTextEditor as any) = undefined;
workspaceState.get.mockReturnValue(false);
});
it('can reveal test explore view', async () => {
(vscode.window.showInformationMessage as jest.Mocked<any>).mockReturnValue(
Expand Down Expand Up @@ -652,11 +651,9 @@ describe('ExtensionManager', () => {
);
await extensionManager.activate();
expect(vscode.window.showInformationMessage).toBeCalled();
expect(workspaceState.get).toBeCalled();
expect(workspaceState.update).toBeCalledWith(expect.anything(), true);

(vscode.window.showInformationMessage as jest.Mocked<any>).mockClear();

workspaceState.get.mockReturnValue(true);
await extensionManager.activate();
expect(vscode.window.showInformationMessage).not.toBeCalled();
});
Expand Down

0 comments on commit 978e4b7

Please sign in to comment.