Skip to content

Commit

Permalink
Mocking browser() call
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuakarp committed Dec 17, 2021
1 parent da50df6 commit 5688a3c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/bin/identities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
import { PolykeyAgent } from '@';
import { makeNodeId } from '@/nodes/utils';
import * as claimsUtils from '@/claims/utils';
import * as identitiesUtils from '@/identities/utils';
import * as testUtils from './utils';
import * as utils from './utils';
import {
Expand Down Expand Up @@ -42,6 +43,7 @@ describe('CLI Identities', () => {
let passwordFile: string;
let polykeyAgent: PolykeyAgent;
let testProvider: TestProvider;
let mockedBrowser: jest.SpyInstance;

// Defining constants
const nodeId1 = makeNodeId(
Expand Down Expand Up @@ -125,6 +127,10 @@ describe('CLI Identities', () => {
testProvider = new TestProvider();
polykeyAgent.identitiesManager.registerProvider(testProvider);

mockedBrowser = jest
.spyOn(identitiesUtils, 'browser')
.mockImplementation(() => {});

// Authorize session
await utils.pkStdio(
['agent', 'unlock', '-np', nodePath, '--password-file', passwordFile],
Expand All @@ -135,6 +141,7 @@ describe('CLI Identities', () => {
afterAll(async () => {
await polykeyAgent.stop();
await polykeyAgent.destroy();
mockedBrowser.mockRestore();
await fs.promises.rmdir(dataDir, { recursive: true });
});
beforeEach(async () => {
Expand Down

0 comments on commit 5688a3c

Please sign in to comment.