From 33b085bf541afff4f2ebd50ea675c1176eaf3c2c Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 16 May 2016 14:33:02 -0300 Subject: [PATCH] Add tests for article content hotspot in comment paragraph --- src/plugins/comment_paragraph/hotspot/article-content/article-content.component.spec.ts | 36 ++++++++++++++++++++++++++++++++++++ src/spec/component-test-helper.ts | 6 ++++++ 2 files changed, 42 insertions(+), 0 deletions(-) create mode 100644 src/plugins/comment_paragraph/hotspot/article-content/article-content.component.spec.ts diff --git a/src/plugins/comment_paragraph/hotspot/article-content/article-content.component.spec.ts b/src/plugins/comment_paragraph/hotspot/article-content/article-content.component.spec.ts new file mode 100644 index 0000000..429f7a1 --- /dev/null +++ b/src/plugins/comment_paragraph/hotspot/article-content/article-content.component.spec.ts @@ -0,0 +1,36 @@ +import {CommentParagraphArticleContentHotspotComponent} from './article-content.component'; +import {ComponentTestHelper, createClass} from './../../../../spec/component-test-helper'; + +const htmlTemplate: string = ''; + +describe("Components", () => { + describe("Article Content Hotspot Component", () => { + + let helper: ComponentTestHelper; + beforeEach(angular.mock.module("templates")); + + beforeEach((done) => { + let properties = { article: {} }; + let cls = createClass({ + template: htmlTemplate, + directives: [CommentParagraphArticleContentHotspotComponent], + properties: properties + }); + helper = new ComponentTestHelper(cls, done); + }); + + it("return false in isDiscussion when no type was specified", () => { + expect(helper.component.isDiscussion()).toBeFalsy(); + }); + + it("return false in isDiscussion when other type was specified", () => { + helper.changeProperties({article: {type: "TextArticle"}}); + expect(helper.component.isDiscussion()).toBeFalsy(); + }); + + it("return true in isDiscussion when discussion type was specified", () => { + helper.changeProperties({article: {type: "CommentParagraphPlugin::Discussion"}}); + expect(helper.component.isDiscussion()).toBeTruthy(); + }); + }); +}); diff --git a/src/spec/component-test-helper.ts b/src/spec/component-test-helper.ts index 20ccb11..590769f 100644 --- a/src/spec/component-test-helper.ts +++ b/src/spec/component-test-helper.ts @@ -98,6 +98,12 @@ export class ComponentTestHelper { }); } + changeProperties(properties: any) { + Object.keys(properties).forEach((key: any) => { + this.component[key] = properties[key]; + }); + } + /** * @ngdoc method * @name detectChanges -- libgit2 0.21.2