diff --git a/src/app/components/noosfero-blocks/main-block/main-block.component.spec.ts b/src/app/components/noosfero-blocks/main-block/main-block.component.spec.ts index fc51131..6a386ad 100644 --- a/src/app/components/noosfero-blocks/main-block/main-block.component.spec.ts +++ b/src/app/components/noosfero-blocks/main-block/main-block.component.spec.ts @@ -36,6 +36,6 @@ describe("Components", () => { done(); }); }); - + }); }); \ No newline at end of file diff --git a/src/app/components/noosfero-blocks/profile-image-block/profile-image-block.component.spec.ts b/src/app/components/noosfero-blocks/profile-image-block/profile-image-block.component.spec.ts index 094f5d6..a0d2705 100644 --- a/src/app/components/noosfero-blocks/profile-image-block/profile-image-block.component.spec.ts +++ b/src/app/components/noosfero-blocks/profile-image-block/profile-image-block.component.spec.ts @@ -15,20 +15,17 @@ describe("Components", () => { beforeEach(angular.mock.module("templates")); - @Component( - { - selector: 'test-container-component', - template: htmlTemplate, - directives: [ProfileImageBlock] - }) + @Component({ + selector: 'test-container-component', + template: htmlTemplate, + directives: [ProfileImageBlock] + }) class BlockContainerComponent { block = { type: 'Block' }; owner = { name: 'profile-name' }; constructor() { } - } - - + } it("show image if present", () => { helpers.tcb.createAsync(BlockContainerComponent).then(fixture => { @@ -37,14 +34,12 @@ describe("Components", () => { }); }); - //TODO - it("not show image if image is missing", () => { - - }); - it("has link to the profile", () => { - + helpers.tcb.createAsync(BlockContainerComponent).then(fixture => { + var elProfile = fixture.debugElement.componentViewChildren[0]; + expect(elProfile.query('a.settings-link').length).toEqual(1); + }); }); - + }); }); \ No newline at end of file diff --git a/src/app/components/noosfero/profile-image/profile-image.component.spec.ts b/src/app/components/noosfero/profile-image/profile-image.component.spec.ts index e69de29..12fe1c9 100644 --- a/src/app/components/noosfero/profile-image/profile-image.component.spec.ts +++ b/src/app/components/noosfero/profile-image/profile-image.component.spec.ts @@ -0,0 +1,45 @@ + +import {TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; +import {Pipe, Input, provide, Component} from 'ng-forward'; + +import * as helpers from "./../../../../spec/helpers"; + +import {ProfileImage} from "./profile-image.component" + +const tcb = new TestComponentBuilder(); + +describe("Components", () => { + + describe("Profile Image Component", () => { + + beforeEach(angular.mock.module("templates")); + + it("show community users image if profile is not Person", done => { + helpers.tcb.createAsync(ProfileImage).then(fixture => { + let profileImageComponent : ProfileImage = fixture.componentInstance + let profile = { id: 1, identifier: "myprofile", type: "Community" } + profileImageComponent.profile = profile + profileImageComponent.ngOnInit(); + + // Check the attribute + expect(profileImageComponent.defaultIcon).toBe("fa-users", "The default icon should be community users"); + //var elProfile = fixture.debugElement.componentViewChildren[0]; + //expect(elProfile.query('div.profile-image-block').length).toEqual(1); + done(); + }); + }); + + it("show Person image if profile is Person", done => { + tcb.createAsync(ProfileImage).then(fixture => { + let profileImageComponent : ProfileImage = fixture.componentInstance + let profile = { id: 1, identifier: "myprofile", type: "Person" } + profileImageComponent.profile = profile + profileImageComponent.ngOnInit(); + // Check the attribute + expect(profileImageComponent.defaultIcon).toEqual("fa-user", "The default icon should be person user"); + done(); + }); + }); + + }); +}); \ No newline at end of file diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index fde107f..6b0f6e9 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -46,12 +46,6 @@ export class MainContent { url: '/', component: MainContent, name: 'main', - resolve: { - currentUser: function(AuthService: AuthService, $log: ng.ILogService) { - $log.debug("Main URL service..."); - return AuthService.currentUser(); - } - } }, { url: "^/:profile", -- libgit2 0.21.2