Skip to content

Commit 44c4d9f

Browse files
Fix tests
1 parent d194ef8 commit 44c4d9f

File tree

9 files changed

+199
-201
lines changed

9 files changed

+199
-201
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"start:local:oidc": "node scripts/oidc-provider",
99
"start:local:playground": "ng serve --configuration=local",
1010
"prebuild": "npm run update-useragent",
11-
"build:dev": "ng build && npm run build:schematics",
12-
"build": "ng build --configuration=production && npm run build:schematics",
11+
"build:dev": "ng build auth0-angular && npm run build:schematics",
12+
"build": "ng build auth0-angular --configuration=production && npm run build:schematics",
1313
"build:schematics": "npm run build --prefix projects/auth0-angular",
1414
"postbuild": "cp README.md ./dist/auth0-angular/",
1515
"test": "jest",

projects/auth0-angular/jest.config.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1+
import { createCjsPreset } from 'jest-preset-angular/presets';
12
/* eslint-disable */
23
export default {
34
displayName: 'auth0-angular',
4-
preset: 'jest-preset-angular',
5+
...createCjsPreset(),
56
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6-
globals: {
7-
'ts-jest': {
8-
tsconfig: '<rootDir>/tsconfig.spec.json',
9-
stringifyContentPathRegex: '\\.(html|svg)$',
10-
},
11-
},
127
coverageDirectory: '../../coverage/auth0-angular',
13-
transform: {
14-
'^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
15-
},
16-
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
178
snapshotSerializers: [
189
'jest-preset-angular/build/serializers/no-ng-attributes',
1910
'jest-preset-angular/build/serializers/ng-snapshot',

projects/auth0-angular/src/lib/abstract-navigator.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { RouterTestingModule } from '@angular/router/testing';
33
import { Location } from '@angular/common';
44
import { AbstractNavigator } from './abstract-navigator';
55
import { Component } from '@angular/core';
6+
import { Router } from '@angular/router';
67

78
describe('RouteNavigator', () => {
89
let navigator: AbstractNavigator;
@@ -14,7 +15,9 @@ describe('RouteNavigator', () => {
1415

1516
describe('with no router', () => {
1617
beforeEach(() => {
17-
TestBed.configureTestingModule({});
18+
TestBed.configureTestingModule({
19+
providers: [{ provide: Router, useValue: null }],
20+
});
1821

1922
navigator = TestBed.inject(AbstractNavigator);
2023

projects/auth0-angular/src/lib/auth.client.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { AuthConfig, AuthClientConfig } from './auth.config';
22
import { Auth0ClientFactory } from './auth.client';
33

4-
const mockWindow = global as any;
4+
const mockWindow = window as any;
55

6-
mockWindow.crypto = {
7-
subtle: {
8-
digest: () => 'foo',
6+
Object.defineProperty(mockWindow, 'crypto', {
7+
value: {
8+
subtle: {
9+
digest: () => 'foo',
10+
},
11+
getRandomValues() {
12+
return '123';
13+
},
914
},
10-
getRandomValues() {
11-
return '123';
12-
},
13-
};
15+
writable: false,
16+
});
1417

1518
describe('Auth0ClientFactory', () => {
1619
describe('createClient', () => {

projects/auth0-angular/src/lib/auth.interceptor.spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ import { AuthService } from './auth.service';
2828

2929
const mockWindow = global as any;
3030

31-
mockWindow.crypto = {
32-
subtle: {
33-
digest: () => 'foo',
31+
Object.defineProperty(mockWindow, 'crypto', {
32+
value: {
33+
subtle: {
34+
digest: () => 'foo',
35+
},
36+
getRandomValues() {
37+
return '123';
38+
},
3439
},
35-
getRandomValues() {
36-
return '123';
37-
},
38-
};
40+
writable: false,
41+
});
3942

4043
describe('The Auth HTTP Interceptor', () => {
4144
let httpClient: HttpClient;

0 commit comments

Comments
 (0)