Commit 2f1cd64d5f287ec990ca1b088538b600d9700be4

Authored by Carlos Purificação
1 parent c77d715c

Fix profile-image tests. Removed resolver from main component

src/app/components/noosfero-blocks/main-block/main-block.component.spec.ts
... ... @@ -36,6 +36,6 @@ describe("Components", () => {
36 36 done();
37 37 });
38 38 });
39   -
  39 +
40 40 });
41 41 });
42 42 \ No newline at end of file
... ...
src/app/components/noosfero-blocks/profile-image-block/profile-image-block.component.spec.ts
... ... @@ -15,20 +15,17 @@ describe("Components", () => {
15 15  
16 16 beforeEach(angular.mock.module("templates"));
17 17  
18   - @Component(
19   - {
20   - selector: 'test-container-component',
21   - template: htmlTemplate,
22   - directives: [ProfileImageBlock]
23   - })
  18 + @Component({
  19 + selector: 'test-container-component',
  20 + template: htmlTemplate,
  21 + directives: [ProfileImageBlock]
  22 + })
24 23 class BlockContainerComponent {
25 24 block = { type: 'Block' };
26 25 owner = { name: 'profile-name' };
27 26 constructor() {
28 27 }
29   - }
30   -
31   -
  28 + }
32 29  
33 30 it("show image if present", () => {
34 31 helpers.tcb.createAsync(BlockContainerComponent).then(fixture => {
... ... @@ -37,14 +34,12 @@ describe("Components", () => {
37 34 });
38 35 });
39 36  
40   - //TODO
41   - it("not show image if image is missing", () => {
42   -
43   - });
44   -
45 37 it("has link to the profile", () => {
46   -
  38 + helpers.tcb.createAsync(BlockContainerComponent).then(fixture => {
  39 + var elProfile = fixture.debugElement.componentViewChildren[0];
  40 + expect(elProfile.query('a.settings-link').length).toEqual(1);
  41 + });
47 42 });
48   -
  43 +
49 44 });
50 45 });
51 46 \ No newline at end of file
... ...
src/app/components/noosfero/profile-image/profile-image.component.spec.ts
... ... @@ -0,0 +1,45 @@
  1 +
  2 +import {TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder';
  3 +import {Pipe, Input, provide, Component} from 'ng-forward';
  4 +
  5 +import * as helpers from "./../../../../spec/helpers";
  6 +
  7 +import {ProfileImage} from "./profile-image.component"
  8 +
  9 +const tcb = new TestComponentBuilder();
  10 +
  11 +describe("Components", () => {
  12 +
  13 + describe("Profile Image Component", () => {
  14 +
  15 + beforeEach(angular.mock.module("templates"));
  16 +
  17 + it("show community users image if profile is not Person", done => {
  18 + helpers.tcb.createAsync(ProfileImage).then(fixture => {
  19 + let profileImageComponent : ProfileImage = fixture.componentInstance
  20 + let profile = { id: 1, identifier: "myprofile", type: "Community" }
  21 + profileImageComponent.profile = profile
  22 + profileImageComponent.ngOnInit();
  23 +
  24 + // Check the attribute
  25 + expect(profileImageComponent.defaultIcon).toBe("fa-users", "The default icon should be community users");
  26 + //var elProfile = fixture.debugElement.componentViewChildren[0];
  27 + //expect(elProfile.query('div.profile-image-block').length).toEqual(1);
  28 + done();
  29 + });
  30 + });
  31 +
  32 + it("show Person image if profile is Person", done => {
  33 + tcb.createAsync(ProfileImage).then(fixture => {
  34 + let profileImageComponent : ProfileImage = fixture.componentInstance
  35 + let profile = { id: 1, identifier: "myprofile", type: "Person" }
  36 + profileImageComponent.profile = profile
  37 + profileImageComponent.ngOnInit();
  38 + // Check the attribute
  39 + expect(profileImageComponent.defaultIcon).toEqual("fa-user", "The default icon should be person user");
  40 + done();
  41 + });
  42 + });
  43 +
  44 + });
  45 +});
0 46 \ No newline at end of file
... ...
src/app/main/main.component.ts
... ... @@ -46,12 +46,6 @@ export class MainContent {
46 46 url: '/',
47 47 component: MainContent,
48 48 name: 'main',
49   - resolve: {
50   - currentUser: function(AuthService: AuthService, $log: ng.ILogService) {
51   - $log.debug("Main URL service...");
52   - return AuthService.currentUser();
53   - }
54   - }
55 49 },
56 50 {
57 51 url: "^/:profile",
... ...