Browse Source

test: fixed the application-configuration.service.spec testing errors

pull/6343/head
mehmet-erim 6 years ago
parent
commit
1b75bc10d1
  1. 28
      npm/ng-packs/packages/core/src/lib/tests/application-configuration.service.spec.ts

28
npm/ng-packs/packages/core/src/lib/tests/application-configuration.service.spec.ts

@ -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…
Cancel
Save