mirror of https://github.com/abpframework/abp.git
1 changed files with 17 additions and 11 deletions
@ -1,21 +1,27 @@ |
|||
import { createHttpFactory, HttpMethod, SpectatorHttp } from '@ngneat/spectator/jest'; |
|||
import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest'; |
|||
import { of } from 'rxjs'; |
|||
import { ApplicationConfigurationService, RestService } from '../services'; |
|||
import { Store } from '@ngxs/store'; |
|||
import { CORE_OPTIONS } from '../tokens'; |
|||
|
|||
describe('ApplicationConfigurationService', () => { |
|||
let spectator: SpectatorHttp<ApplicationConfigurationService>; |
|||
const createHttp = createHttpFactory({ |
|||
dataService: ApplicationConfigurationService, |
|||
providers: [RestService, { provide: CORE_OPTIONS, useValue: { environment: {} } }], |
|||
mocks: [Store], |
|||
let spectator: SpectatorService<ApplicationConfigurationService>; |
|||
const createService = createServiceFactory({ |
|||
service: ApplicationConfigurationService, |
|||
mocks: [RestService], |
|||
}); |
|||
|
|||
beforeEach(() => (spectator = createHttp())); |
|||
beforeEach(() => (spectator = createService())); |
|||
|
|||
it('should send a GET to application-configuration API', () => { |
|||
spectator.inject(Store).selectSnapshot.andReturn('https://abp.io'); |
|||
const rest = spectator.inject(RestService); |
|||
|
|||
const requestSpy = jest.spyOn(rest, 'request'); |
|||
requestSpy.mockReturnValue(of(null)); |
|||
|
|||
spectator.service.getConfiguration().subscribe(); |
|||
spectator.expectOne('https://abp.io/api/abp/application-configuration', HttpMethod.GET); |
|||
|
|||
expect(requestSpy).toHaveBeenCalledWith( |
|||
{ method: 'GET', url: '/api/abp/application-configuration' }, |
|||
{}, |
|||
); |
|||
}); |
|||
}); |
|||
|
|||
Loading…
Reference in new issue