Commit 33b085bf541afff4f2ebd50ea675c1176eaf3c2c
1 parent
bdd5ee03
Exists in
master
and in
26 other branches
Add tests for article content hotspot in comment paragraph
Showing
2 changed files
with
42 additions
and
0 deletions
Show diff stats
src/plugins/comment_paragraph/hotspot/article-content/article-content.component.spec.ts
0 → 100644
... | ... | @@ -0,0 +1,36 @@ |
1 | +import {CommentParagraphArticleContentHotspotComponent} from './article-content.component'; | |
2 | +import {ComponentTestHelper, createClass} from './../../../../spec/component-test-helper'; | |
3 | + | |
4 | +const htmlTemplate: string = '<comment-paragraph-article-content-hotspot [article]="ctrl.article"></comment-paragraph-article-content-hotspot>'; | |
5 | + | |
6 | +describe("Components", () => { | |
7 | + describe("Article Content Hotspot Component", () => { | |
8 | + | |
9 | + let helper: ComponentTestHelper<CommentParagraphArticleContentHotspotComponent>; | |
10 | + beforeEach(angular.mock.module("templates")); | |
11 | + | |
12 | + beforeEach((done) => { | |
13 | + let properties = { article: {} }; | |
14 | + let cls = createClass({ | |
15 | + template: htmlTemplate, | |
16 | + directives: [CommentParagraphArticleContentHotspotComponent], | |
17 | + properties: properties | |
18 | + }); | |
19 | + helper = new ComponentTestHelper<CommentParagraphArticleContentHotspotComponent>(cls, done); | |
20 | + }); | |
21 | + | |
22 | + it("return false in isDiscussion when no type was specified", () => { | |
23 | + expect(helper.component.isDiscussion()).toBeFalsy(); | |
24 | + }); | |
25 | + | |
26 | + it("return false in isDiscussion when other type was specified", () => { | |
27 | + helper.changeProperties({article: {type: "TextArticle"}}); | |
28 | + expect(helper.component.isDiscussion()).toBeFalsy(); | |
29 | + }); | |
30 | + | |
31 | + it("return true in isDiscussion when discussion type was specified", () => { | |
32 | + helper.changeProperties({article: {type: "CommentParagraphPlugin::Discussion"}}); | |
33 | + expect(helper.component.isDiscussion()).toBeTruthy(); | |
34 | + }); | |
35 | + }); | |
36 | +}); | ... | ... |
src/spec/component-test-helper.ts
... | ... | @@ -98,6 +98,12 @@ export class ComponentTestHelper<T extends any> { |
98 | 98 | }); |
99 | 99 | } |
100 | 100 | |
101 | + changeProperties(properties: any) { | |
102 | + Object.keys(properties).forEach((key: any) => { | |
103 | + this.component[key] = properties[key]; | |
104 | + }); | |
105 | + } | |
106 | + | |
101 | 107 | /** |
102 | 108 | * @ngdoc method |
103 | 109 | * @name detectChanges | ... | ... |