Commit 56a68d9b71a71cf254f378cc341cdbff03238047
1 parent
37469833
Exists in
master
and in
30 other branches
Add tests to comment component
Showing
1 changed file
with
44 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,44 @@ |
1 | +import {Provider, provide, Component} from 'ng-forward'; | |
2 | +import * as helpers from "../../../spec/helpers"; | |
3 | + | |
4 | +import {CommentComponent} from './comment.component'; | |
5 | + | |
6 | +const htmlTemplate: string = '<noosfero-comment [article]="ctrl.article" [comment]="ctrl.comment"></noosfero-comment>'; | |
7 | + | |
8 | +describe("Components", () => { | |
9 | + describe("Comment Component", () => { | |
10 | + | |
11 | + beforeEach(angular.mock.module("templates")); | |
12 | + | |
13 | + @Component({ selector: 'test-container-component', directives: [CommentComponent], template: htmlTemplate, providers: helpers.provideFilters("translateFilter") }) | |
14 | + class ContainerComponent { | |
15 | + article = { id: 1 }; | |
16 | + comment = { title: "title", body: "body" }; | |
17 | + } | |
18 | + | |
19 | + it("render a comment", done => { | |
20 | + helpers.createComponentFromClass(ContainerComponent).then(fixture => { | |
21 | + expect(fixture.debugElement.queryAll(".comment").length).toEqual(1); | |
22 | + done(); | |
23 | + }); | |
24 | + }); | |
25 | + | |
26 | + it("not render a post comment tag in the beginning", done => { | |
27 | + helpers.createComponentFromClass(ContainerComponent).then(fixture => { | |
28 | + expect(fixture.debugElement.queryAll("noosfero-post-comment").length).toEqual(0); | |
29 | + done(); | |
30 | + }); | |
31 | + }); | |
32 | + | |
33 | + it("render a post comment tag when click in reply", done => { | |
34 | + helpers.createComponentFromClass(ContainerComponent).then(fixture => { | |
35 | + let component: CommentComponent = fixture.debugElement.componentViewChildren[0].componentInstance; | |
36 | + component.reply(); | |
37 | + fixture.debugElement.getLocal("$rootScope").$apply(); | |
38 | + expect(fixture.debugElement.queryAll("noosfero-post-comment").length).toEqual(1); | |
39 | + done(); | |
40 | + }); | |
41 | + }); | |
42 | + | |
43 | + }); | |
44 | +}); | ... | ... |