From 331b958528395ea22d369f42b186784d23406234 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Fri, 11 Mar 2016 18:35:58 -0300 Subject: [PATCH] Created initial profile view data directive with two specs --- src/app/components/noosfero-profile/profile-view.component.spec.ts | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/app/components/noosfero-profile/profile-view.component.ts | 11 +++++++++++ src/app/components/noosfero-profile/profile-view.html | 15 +++++++++++++++ src/languages/en.json | 1 + 4 files changed, 81 insertions(+), 0 deletions(-) create mode 100644 src/app/components/noosfero-profile/profile-view.component.spec.ts create mode 100644 src/app/components/noosfero-profile/profile-view.component.ts create mode 100644 src/app/components/noosfero-profile/profile-view.html diff --git a/src/app/components/noosfero-profile/profile-view.component.spec.ts b/src/app/components/noosfero-profile/profile-view.component.spec.ts new file mode 100644 index 0000000..22dec92 --- /dev/null +++ b/src/app/components/noosfero-profile/profile-view.component.spec.ts @@ -0,0 +1,54 @@ +import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; +import {Profile} from "./../../models/interfaces"; +import * as helpers from "../../../spec/helpers"; +import {Component} from 'ng-forward' + +import {ProfileView} from './profile-view.component'; + +import {INgForwardJQuery} from '../../../../node_modules/ng-forward/cjs/util/jqlite-extensions.d'; + +let htmlTemplate = '' +describe('Profile View Component', () => { + beforeEach(angular.mock.module('templates')) + @Component({ + selector: 'test-profile-view-container', + directives: [ProfileView], + providers: helpers.provideFilters('translateFilter'), + template: htmlTemplate + }) + class ProfileViewContainer { + profile: any = { + id: 1, + identifier: 'scarlet', + type: 'Profile', + name: 'Scarlet', + created_at: '2016-03-11' + } + } + + it('render main content profile view', (done: Function) => { + helpers.createComponentFromClass(ProfileViewContainer).then((fixture) => { + expect(fixture.debugElement.query('div.profile-view').length).toEqual(1); + + done(); + }) + .catch((e) => { + fail(e.message); + done(); + }); + + }); + + it('render profile data', (done: Function) => { + helpers.createComponentFromClass(ProfileViewContainer).then((fixture) => { + let nameTag: INgForwardJQuery = fixture.debugElement.query('header > h2'); + let container: ProfileViewContainer = fixture.componentInstance; + + + expect(nameTag.length).toEqual(1); + expect(nameTag.text()).toEqual(container.profile.name); + + done(); + }) + }); +}); diff --git a/src/app/components/noosfero-profile/profile-view.component.ts b/src/app/components/noosfero-profile/profile-view.component.ts new file mode 100644 index 0000000..7b974ef --- /dev/null +++ b/src/app/components/noosfero-profile/profile-view.component.ts @@ -0,0 +1,11 @@ +import {Profile} from "../../models/interfaces"; +import {Component, Input} from 'ng-forward' + +@Component({ + selector: 'profile-view', + templateUrl: 'app/components/noosfero-profile/profile-view.html' +}) +export class ProfileView { + @Input() + profile: Profile +} diff --git a/src/app/components/noosfero-profile/profile-view.html b/src/app/components/noosfero-profile/profile-view.html new file mode 100644 index 0000000..9cef780 --- /dev/null +++ b/src/app/components/noosfero-profile/profile-view.html @@ -0,0 +1,15 @@ +
+
+
+
+

{{ctrl.profile.name}}

+
+
+ +
+
+ {{"profile.created_at" | translate}}: {{ctrl.profile.created_at}} +
+
+
+
diff --git a/src/languages/en.json b/src/languages/en.json index ae094bb..5d25edf 100644 --- a/src/languages/en.json +++ b/src/languages/en.json @@ -12,6 +12,7 @@ "profile.wall": "Profile Wall", "activities.create_article.description": "has published on", "activities.add_member_in_community.description": "has joined the community", + "profile.member_since": "Member since" "activities.new_friendship.description": "has made {friends, plural, one{one new friend} other{# new friends}}:", "auth.title": "Login", "auth.form.login": "Login / Email address", -- libgit2 0.21.2