mirror of https://github.com/abpframework/abp.git
1 changed files with 72 additions and 0 deletions
@ -0,0 +1,72 @@ |
|||
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest'; |
|||
import { Environment } from '../models'; |
|||
import { EnvironmentService } from '../services'; |
|||
|
|||
export const ENVIRONMENT_DATA = ({ |
|||
production: false, |
|||
application: { |
|||
name: 'MyProjectName', |
|||
}, |
|||
oAuthConfig: { |
|||
issuer: 'https://localhost:44305', |
|||
}, |
|||
apis: { |
|||
default: { |
|||
url: 'https://localhost:44305', |
|||
}, |
|||
other: { |
|||
url: 'https://localhost:44306', |
|||
}, |
|||
}, |
|||
localization: { |
|||
defaultResourceName: 'MyProjectName', |
|||
}, |
|||
} as any) as Environment; |
|||
|
|||
describe('ConfigState', () => { |
|||
let spectator: SpectatorService<EnvironmentService>; |
|||
let environment: EnvironmentService; |
|||
|
|||
const createService = createServiceFactory({ |
|||
service: EnvironmentService, |
|||
}); |
|||
|
|||
beforeEach(() => { |
|||
spectator = createService(); |
|||
environment = spectator.service; |
|||
|
|||
environment.setState(ENVIRONMENT_DATA); |
|||
}); |
|||
|
|||
describe('#getEnvironment', () => { |
|||
it('should return ENVIRONMENT_DATA', () => { |
|||
expect(environment.getEnvironment()).toEqual(ENVIRONMENT_DATA); |
|||
environment.getEnvironment$().subscribe(data => expect(data).toEqual(ENVIRONMENT_DATA)); |
|||
}); |
|||
}); |
|||
|
|||
describe('#getApiUrl', () => { |
|||
it('should return api url', () => { |
|||
expect(environment.getApiUrl()).toEqual(ENVIRONMENT_DATA.apis.default.url); |
|||
environment |
|||
.getApiUrl$('other') |
|||
.subscribe(data => expect(data).toEqual(ENVIRONMENT_DATA.apis.other.url)); |
|||
}); |
|||
}); |
|||
|
|||
// TODO: create permission.service.spec.ts
|
|||
// describe('#getGrantedPolicy', () => {
|
|||
// it('should return a granted policy', () => {
|
|||
// expect(ConfigState.getGrantedPolicy('Abp.Identity')(CONFIG_STATE_DATA)).toBe(false);
|
|||
// expect(ConfigState.getGrantedPolicy('Abp.Identity || Abp.Account')(CONFIG_STATE_DATA)).toBe(
|
|||
// true,
|
|||
// );
|
|||
// expect(ConfigState.getGrantedPolicy('Abp.Account && Abp.Identity')(CONFIG_STATE_DATA)).toBe(
|
|||
// false,
|
|||
// );
|
|||
// expect(ConfigState.getGrantedPolicy('Abp.Account &&')(CONFIG_STATE_DATA)).toBe(false);
|
|||
// expect(ConfigState.getGrantedPolicy('|| Abp.Account')(CONFIG_STATE_DATA)).toBe(false);
|
|||
// expect(ConfigState.getGrantedPolicy('')(CONFIG_STATE_DATA)).toBe(true);
|
|||
// });
|
|||
// });
|
|||
}); |
|||
Loading…
Reference in new issue