feat: init

This commit is contained in:
2025-01-30 20:02:28 +08:00
parent da0d9855da
commit 1785df25e2
125 changed files with 8601 additions and 4725 deletions

View File

@@ -1,7 +1,7 @@
import { APP_INITIALIZER } from '@angular/core';
import { TestBed, waitForAsync } from '@angular/core/testing';
import { TestBed, createSpyObj } from '@/testing';
import { mockProvider } from '@/testing/mock';
import { APP_INITIALIZER } from 'oidc-client-rx';
import { of } from 'rxjs';
import { mockProvider } from '../test/auto-mock';
import { PASSED_CONFIG } from './auth-config';
import { ConfigurationService } from './config/config.service';
import {
@@ -14,14 +14,14 @@ import { provideAuth, withAppInitializerAuthCheck } from './provide-auth';
describe('provideAuth', () => {
describe('APP_CONFIG', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
beforeEach(async () => {
await TestBed.configureTestingModule({
providers: [
provideAuth({ config: { authority: 'something' } }),
mockProvider(ConfigurationService),
],
}).compileComponents();
}));
});
it('should provide config', () => {
const config = TestBed.inject(PASSED_CONFIG);
@@ -37,8 +37,8 @@ describe('provideAuth', () => {
});
describe('StsConfigHttpLoader', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
beforeEach(async () => {
await TestBed.configureTestingModule({
providers: [
provideAuth({
loader: {
@@ -49,7 +49,7 @@ describe('provideAuth', () => {
mockProvider(ConfigurationService),
],
}).compileComponents();
}));
});
it('should create StsConfigStaticLoader if config is passed', () => {
const configLoader = TestBed.inject(StsConfigLoader);
@@ -59,14 +59,14 @@ describe('provideAuth', () => {
});
describe('features', () => {
let oidcSecurityServiceMock: jasmine.SpyObj<OidcSecurityService>;
let oidcSecurityServiceMock: OidcSecurityService;
beforeEach(waitForAsync(() => {
oidcSecurityServiceMock = jasmine.createSpyObj<OidcSecurityService>(
beforeEach(async () => {
oidcSecurityServiceMock = createSpyObj<OidcSecurityService>(
'OidcSecurityService',
['checkAuthMultiple']
);
TestBed.configureTestingModule({
await TestBed.configureTestingModule({
providers: [
provideAuth(
{ config: { authority: 'something' } },
@@ -79,14 +79,15 @@ describe('provideAuth', () => {
},
],
}).compileComponents();
}));
});
it('should provide APP_INITIALIZER config', () => {
const config = TestBed.inject(APP_INITIALIZER);
expect(config.length)
.withContext('Expected an APP_INITIALIZER to be registered')
.toBe(1);
expect(
config.length,
'Expected an APP_INITIALIZER to be registered'
).toBe(1);
expect(oidcSecurityServiceMock.checkAuthMultiple).toHaveBeenCalledTimes(
1
);