feat: init and fork some code from angular-auth-oidc-client
Some checks are pending
Build, Lint & Test Lib / Built, Lint and Test Library (push) Waiting to run
Build, Lint & Test Lib / Angular latest (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest Standalone & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular 16 & RxJs 6 (push) Blocked by required conditions
Build, Lint & Test Lib / Angular V16 (push) Blocked by required conditions
Docs / Build and Deploy Docs Job (push) Waiting to run
Docs / Close Pull Request Job (push) Waiting to run
Some checks are pending
Build, Lint & Test Lib / Built, Lint and Test Library (push) Waiting to run
Build, Lint & Test Lib / Angular latest (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest Standalone & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular 16 & RxJs 6 (push) Blocked by required conditions
Build, Lint & Test Lib / Angular V16 (push) Blocked by required conditions
Docs / Build and Deploy Docs Job (push) Waiting to run
Docs / Close Pull Request Job (push) Waiting to run
This commit is contained in:
75
src/flows/reset-auth-data.service.spec.ts
Normal file
75
src/flows/reset-auth-data.service.spec.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { mockProvider } from '../../test/auto-mock';
|
||||
import { AuthStateService } from '../auth-state/auth-state.service';
|
||||
import { LoggerService } from '../logging/logger.service';
|
||||
import { UserService } from '../user-data/user.service';
|
||||
import { FlowsDataService } from './flows-data.service';
|
||||
import { ResetAuthDataService } from './reset-auth-data.service';
|
||||
|
||||
describe('ResetAuthDataService', () => {
|
||||
let service: ResetAuthDataService;
|
||||
let userService: UserService;
|
||||
let flowsDataService: FlowsDataService;
|
||||
let authStateService: AuthStateService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
ResetAuthDataService,
|
||||
mockProvider(AuthStateService),
|
||||
mockProvider(FlowsDataService),
|
||||
mockProvider(UserService),
|
||||
mockProvider(LoggerService),
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = TestBed.inject(ResetAuthDataService);
|
||||
userService = TestBed.inject(UserService);
|
||||
flowsDataService = TestBed.inject(FlowsDataService);
|
||||
authStateService = TestBed.inject(AuthStateService);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('resetAuthorizationData', () => {
|
||||
it('calls resetUserDataInStore when autoUserInfo is true', () => {
|
||||
const resetUserDataInStoreSpy = spyOn(
|
||||
userService,
|
||||
'resetUserDataInStore'
|
||||
);
|
||||
const allConfigs = [
|
||||
{
|
||||
configId: 'configId1',
|
||||
},
|
||||
];
|
||||
|
||||
service.resetAuthorizationData(allConfigs[0], allConfigs);
|
||||
expect(resetUserDataInStoreSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('calls correct methods', () => {
|
||||
const resetStorageFlowDataSpy = spyOn(
|
||||
flowsDataService,
|
||||
'resetStorageFlowData'
|
||||
);
|
||||
const setUnauthorizedAndFireEventSpy = spyOn(
|
||||
authStateService,
|
||||
'setUnauthenticatedAndFireEvent'
|
||||
);
|
||||
const allConfigs = [
|
||||
{
|
||||
configId: 'configId1',
|
||||
},
|
||||
];
|
||||
|
||||
service.resetAuthorizationData(allConfigs[0], allConfigs);
|
||||
|
||||
expect(resetStorageFlowDataSpy).toHaveBeenCalled();
|
||||
expect(setUnauthorizedAndFireEventSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user