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 { ApplicationConfigurationService, RestService } from '../services'; |
||||
import { Store } from '@ngxs/store'; |
|
||||
import { CORE_OPTIONS } from '../tokens'; |
|
||||
|
|
||||
describe('ApplicationConfigurationService', () => { |
describe('ApplicationConfigurationService', () => { |
||||
let spectator: SpectatorHttp<ApplicationConfigurationService>; |
let spectator: SpectatorService<ApplicationConfigurationService>; |
||||
const createHttp = createHttpFactory({ |
const createService = createServiceFactory({ |
||||
dataService: ApplicationConfigurationService, |
service: ApplicationConfigurationService, |
||||
providers: [RestService, { provide: CORE_OPTIONS, useValue: { environment: {} } }], |
mocks: [RestService], |
||||
mocks: [Store], |
|
||||
}); |
}); |
||||
|
|
||||
beforeEach(() => (spectator = createHttp())); |
beforeEach(() => (spectator = createService())); |
||||
|
|
||||
it('should send a GET to application-configuration API', () => { |
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.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