CommunitySolidServer/test/unit/identity/IdentityUtil.test.ts
Joachim Van Herwegen a47f5236ef feat: Full rework of account management
Complete rewrite of the account management and related systems.
Makes the architecture more modular,
allowing for easier extensions and configurations.
2023-10-06 11:04:40 +02:00

25 lines
906 B
TypeScript

import { importOidcProvider } from '../../../src/identity/IdentityUtil';
describe('IdentityUtil', (): void => {
it('avoids dynamic imports when testing with Jest.', async(): Promise<void> => {
const oidc = await importOidcProvider();
expect(oidc.default).toBeDefined();
expect(oidc.interactionPolicy).toBeDefined();
});
it('imports the oidc-provider package when not running jest.', async(): Promise<void> => {
// We need to fool the IDP factory into thinking we are not in a test run
const jestWorkerId = process.env.JEST_WORKER_ID;
const nodeEnv = process.env.NODE_ENV;
delete process.env.JEST_WORKER_ID;
delete process.env.NODE_ENV;
const oidc = await importOidcProvider();
expect(oidc.default).toBeDefined();
expect(oidc.interactionPolicy).toBeDefined();
process.env.JEST_WORKER_ID = jestWorkerId;
process.env.NODE_ENV = nodeEnv;
});
});