Commit 74c79a6498da2bafc7aad3bbb28b7d376beb38d6
1 parent
7557eb0d
Exists in
master
and in
34 other branches
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 | import {Profile} from "../../../app/models/interfaces"; | 1 | import {Profile} from "../../../app/models/interfaces"; |
2 | import {ProfileService} from "./profile.service"; | 2 | import {ProfileService} from "./profile.service"; |
3 | - | 3 | +import {getAngularService} from "../../../spec/helpers"; |
4 | 4 | ||
5 | describe("Services", () => { | 5 | describe("Services", () => { |
6 | 6 | ||
@@ -8,15 +8,16 @@ describe("Services", () => { | @@ -8,15 +8,16 @@ describe("Services", () => { | ||
8 | 8 | ||
9 | let $httpBackend: ng.IHttpBackendService; | 9 | let $httpBackend: ng.IHttpBackendService; |
10 | let profileService: ProfileService; | 10 | let profileService: ProfileService; |
11 | + let $rootScope: ng.IRootScopeService; | ||
11 | 12 | ||
12 | beforeEach(angular.mock.module("noosferoApp")); | 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 | $httpBackend = _$httpBackend_; | 16 | $httpBackend = _$httpBackend_; |
16 | profileService = _ProfileService_; | 17 | profileService = _ProfileService_; |
18 | + $rootScope = _$rootScope_; | ||
17 | })); | 19 | })); |
18 | 20 | ||
19 | - | ||
20 | describe("Succesfull requests", () => { | 21 | describe("Succesfull requests", () => { |
21 | 22 | ||
22 | it("should return profile by its identifier", (done) => { | 23 | it("should return profile by its identifier", (done) => { |
@@ -58,6 +59,17 @@ describe("Services", () => { | @@ -58,6 +59,17 @@ describe("Services", () => { | ||
58 | }); | 59 | }); |
59 | $httpBackend.flush(); | 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 |