Commit 74c79a6498da2bafc7aad3bbb28b7d376beb38d6
1 parent
7557eb0d
Exists in
master
and in
1 other branch
Add test for current profile in profile service
Showing
1 changed file
with
15 additions
and
3 deletions
Show diff stats
src/lib/ng-noosfero-api/http/profile.service.spec.ts
| 1 | 1 | import {Profile} from "../../../app/models/interfaces"; |
| 2 | 2 | import {ProfileService} from "./profile.service"; |
| 3 | - | |
| 3 | +import {getAngularService} from "../../../spec/helpers"; | |
| 4 | 4 | |
| 5 | 5 | describe("Services", () => { |
| 6 | 6 | |
| ... | ... | @@ -8,15 +8,16 @@ describe("Services", () => { |
| 8 | 8 | |
| 9 | 9 | let $httpBackend: ng.IHttpBackendService; |
| 10 | 10 | let profileService: ProfileService; |
| 11 | + let $rootScope: ng.IRootScopeService; | |
| 11 | 12 | |
| 12 | 13 | beforeEach(angular.mock.module("noosferoApp")); |
| 13 | 14 | |
| 14 | - beforeEach(inject((_$httpBackend_: ng.IHttpBackendService, _ProfileService_: ProfileService) => { | |
| 15 | + beforeEach(inject((_$httpBackend_: ng.IHttpBackendService, _ProfileService_: ProfileService, _$rootScope_: ng.IRootScopeService) => { | |
| 15 | 16 | $httpBackend = _$httpBackend_; |
| 16 | 17 | profileService = _ProfileService_; |
| 18 | + $rootScope = _$rootScope_; | |
| 17 | 19 | })); |
| 18 | 20 | |
| 19 | - | |
| 20 | 21 | describe("Succesfull requests", () => { |
| 21 | 22 | |
| 22 | 23 | it("should return profile by its identifier", (done) => { |
| ... | ... | @@ -58,6 +59,17 @@ describe("Services", () => { |
| 58 | 59 | }); |
| 59 | 60 | $httpBackend.flush(); |
| 60 | 61 | }); |
| 62 | + | |
| 63 | + it("should resolve the current profile", (done) => { | |
| 64 | + let profile: Profile = { id: 1, identifier: "profile1" }; | |
| 65 | + profileService.getCurrentProfile().then((currentProfile: Profile) => { | |
| 66 | + expect(currentProfile).toEqual(currentProfile); | |
| 67 | + done(); | |
| 68 | + }); | |
| 69 | + profileService.setCurrentProfile(profile); | |
| 70 | + $rootScope.$apply(); | |
| 71 | + }); | |
| 72 | + | |
| 61 | 73 | }); |
| 62 | 74 | |
| 63 | 75 | ... | ... |