Commit 29d769adba521cb06293d7ac5dc42e9a09673d0b

Authored by Victor Costa
1 parent 076a7f18

Add tests for discussion editor in comment paragraph

src/plugins/comment_paragraph/article/cms/discussion-editor/discussion-editor.component.spec.ts 0 → 100644
... ... @@ -0,0 +1,42 @@
  1 +import {DiscussionEditorComponent} from './discussion-editor.component';
  2 +import {ComponentTestHelper, createClass} from './../../../../../spec/component-test-helper';
  3 +
  4 +const htmlTemplate: string = '<comment-paragraph-plugin-discussion-editor [article]="ctrl.article"></comment-paragraph-plugin-discussion-editor>';
  5 +
  6 +describe("Components", () => {
  7 + describe("Discussion Editor Component", () => {
  8 +
  9 + let helper: ComponentTestHelper<DiscussionEditorComponent>;
  10 + beforeEach(angular.mock.module("templates"));
  11 +
  12 + beforeEach((done) => {
  13 + let properties = { article: {} };
  14 + let cls = createClass({
  15 + template: htmlTemplate,
  16 + directives: [DiscussionEditorComponent],
  17 + properties: properties
  18 + });
  19 + helper = new ComponentTestHelper<DiscussionEditorComponent>(cls, done);
  20 + });
  21 +
  22 + it("set start_date as article start_date when it was defined", () => {
  23 + let article = {start_date: new Date()};
  24 + helper.changeProperties({article: article});
  25 + helper.component.ngOnInit();
  26 + expect(helper.component.start_date.getTime()).toEqual(article.start_date.getTime());
  27 + });
  28 +
  29 + it("set start_date as current date when it was not defined", () => {
  30 + helper.changeProperties({article: {}});
  31 + helper.component.ngOnInit();
  32 + expect(helper.component.start_date.getTime()).toBeDefined();
  33 + });
  34 +
  35 + it("set end_date as article end_date when it was defined", () => {
  36 + let article = {end_date: new Date()};
  37 + helper.changeProperties({article: article});
  38 + helper.component.ngOnInit();
  39 + expect(helper.component.end_date.getTime()).toEqual(article.end_date.getTime());
  40 + });
  41 + });
  42 +});
... ...