Commit 1efb68f32bcbd7016161b7daf47e2da951705f86
1 parent
13616e88
Exists in
master
and in
33 other branches
Add tests to profile info component
Showing
1 changed file
with
40 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,40 @@ |
1 | +import {quickCreateComponent} from "../../spec/helpers"; | |
2 | +import {ProfileInfo} from "./profile-info.component"; | |
3 | + | |
4 | +describe("Components", () => { | |
5 | + describe("Profile Info Component", () => { | |
6 | + | |
7 | + let $rootScope: ng.IRootScopeService; | |
8 | + let $q: ng.IQService; | |
9 | + let profileServiceMock: any; | |
10 | + let $stateParams: any; | |
11 | + | |
12 | + beforeEach(inject((_$rootScope_: ng.IRootScopeService, _$q_: ng.IQService) => { | |
13 | + $rootScope = _$rootScope_; | |
14 | + $q = _$q_; | |
15 | + })); | |
16 | + | |
17 | + beforeEach(() => { | |
18 | + $stateParams = jasmine.createSpyObj("$stateParams", ["profile"]); | |
19 | + profileServiceMock = jasmine.createSpyObj("profileServiceMock", ["getCurrentProfile", "getActivities"]); | |
20 | + | |
21 | + let getCurrentProfileResponse = $q.defer(); | |
22 | + getCurrentProfileResponse.resolve({ id: 1 }); | |
23 | + | |
24 | + let getActivitiesResponse = $q.defer(); | |
25 | + getActivitiesResponse.resolve({ data: { activities: [{ id: 1 }, { id: 2 }] } }); | |
26 | + | |
27 | + profileServiceMock.getCurrentProfile = jasmine.createSpy("getCurrentProfile").and.returnValue(getCurrentProfileResponse.promise); | |
28 | + profileServiceMock.getActivities = jasmine.createSpy("getActivities").and.returnValue(getActivitiesResponse.promise); | |
29 | + }); | |
30 | + | |
31 | + it("get the profile activities", done => { | |
32 | + let component: ProfileInfo = new ProfileInfo(profileServiceMock); | |
33 | + $rootScope.$apply(); | |
34 | + expect(profileServiceMock.getCurrentProfile).toHaveBeenCalled(); | |
35 | + expect(profileServiceMock.getActivities).toHaveBeenCalled(); | |
36 | + expect(component.activities).toEqual([{ id: 1 }, { id: 2 }]); | |
37 | + done(); | |
38 | + }); | |
39 | + }); | |
40 | +}); | ... | ... |