diff --git a/npm/ng-packs/packages/core/src/lib/tests/application-configuration.service.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/application-configuration.service.spec.ts index 9337eec191..4aa1a98e7a 100644 --- a/npm/ng-packs/packages/core/src/lib/tests/application-configuration.service.spec.ts +++ b/npm/ng-packs/packages/core/src/lib/tests/application-configuration.service.spec.ts @@ -12,7 +12,7 @@ describe('ApplicationConfigurationService', () => { beforeEach(() => (spectator = createHttp())); - it('can test HttpClient.get', () => { + it('should send a GET to application-configuration API', () => { spectator.get(Store).selectSnapshot.andReturn('https://abp.io'); spectator.service.getConfiguration().subscribe(); spectator.expectOne('https://abp.io/api/abp/application-configuration', HttpMethod.GET); diff --git a/npm/ng-packs/packages/core/src/lib/tests/profile.service.spec.ts b/npm/ng-packs/packages/core/src/lib/tests/profile.service.spec.ts new file mode 100644 index 0000000000..6dac6f4bb5 --- /dev/null +++ b/npm/ng-packs/packages/core/src/lib/tests/profile.service.spec.ts @@ -0,0 +1,42 @@ +import { createHttpFactory, HttpMethod, SpectatorHttp } from '@ngneat/spectator/jest'; +import { ProfileService, RestService } from '../services'; +import { Store } from '@ngxs/store'; + +describe('ProfileService', () => { + let spectator: SpectatorHttp; + const createHttp = createHttpFactory({ + dataService: ProfileService, + providers: [RestService], + mocks: [Store], + }); + + beforeEach(() => (spectator = createHttp())); + + it('should send a GET to my-profile API', () => { + spectator.get(Store).selectSnapshot.andReturn('https://abp.io'); + spectator.service.get().subscribe(); + spectator.expectOne('https://abp.io/api/identity/my-profile', HttpMethod.GET); + }); + + it('should send a POST to change-password API', () => { + const mock = { currentPassword: 'test', newPassword: 'test' }; + spectator.get(Store).selectSnapshot.andReturn('https://abp.io'); + spectator.service.changePassword(mock).subscribe(); + const req = spectator.expectOne('https://abp.io/api/identity/my-profile/change-password', HttpMethod.POST); + expect(req.request.body).toEqual(mock); + }); + + it('should send a PUT to my-profile API', () => { + const mock = { + email: 'info@volosoft.com', + userName: 'admin', + name: 'John', + surname: 'Doe', + phoneNumber: '+123456', + }; + spectator.get(Store).selectSnapshot.andReturn('https://abp.io'); + spectator.service.update(mock).subscribe(); + const req = spectator.expectOne('https://abp.io/api/identity/my-profile', HttpMethod.PUT); + expect(req.request.body).toEqual(mock); + }); +});