feat: fix api spec errors

This commit is contained in:
2025-02-04 08:00:00 +08:00
parent 26a06fdbf0
commit f00c1d1aef
7 changed files with 182 additions and 48 deletions

View File

@@ -12,32 +12,36 @@ import { mockProvider } from './testing/mock';
describe('AuthModule', () => {
describe('APP_CONFIG', () => {
let authModule: AuthModule;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AuthModule.forRoot({ config: { authority: 'something' } })],
providers: [mockProvider(ConfigurationService)],
}).compileComponents();
authModule = TestBed.getImportByType(AuthModule);
});
it('should create', () => {
expect(AuthModule).toBeDefined();
expect(new AuthModule()).toBeDefined();
expect(authModule).toBeDefined();
});
it('should provide config', () => {
const config = TestBed.inject(PASSED_CONFIG);
const config = authModule.get(PASSED_CONFIG);
expect(config).toEqual({ config: { authority: 'something' } });
});
it('should create StsConfigStaticLoader if config is passed', () => {
const configLoader = TestBed.inject(StsConfigLoader);
const configLoader = authModule.get(StsConfigLoader);
expect(configLoader instanceof StsConfigStaticLoader).toBe(true);
});
});
describe('StsConfigHttpLoader', () => {
let authModule: AuthModule;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
@@ -50,10 +54,11 @@ describe('AuthModule', () => {
],
providers: [mockProvider(ConfigurationService)],
}).compileComponents();
authModule = TestBed.getImportByType(AuthModule);
});
it('should create StsConfigStaticLoader if config is passed', () => {
const configLoader = TestBed.inject(StsConfigLoader);
const configLoader = authModule.get(StsConfigLoader);
expect(configLoader instanceof StsConfigHttpLoader).toBe(true);
});