From da32e0223b6c2bfd9f876d8cdbe43a1e3ac9b7a3 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Tue, 10 May 2016 09:18:53 -0300 Subject: [PATCH] refactoring raw html block --- src/app/layout/blocks/raw-html/index.ts | 2 +- src/app/layout/blocks/raw-html/raw-html-block.component.spec.ts | 36 ++++++++++++++++++++++++++++++++++++ src/app/layout/blocks/raw-html/raw-html-block.component.ts | 18 ++++++++++++++++++ src/app/layout/blocks/raw-html/raw-html-block.html | 2 ++ src/app/layout/blocks/raw-html/raw-html.component.spec.ts | 36 ------------------------------------ src/app/layout/blocks/raw-html/raw-html.component.ts | 18 ------------------ src/app/layout/blocks/raw-html/raw-html.html | 2 -- src/app/main/main.component.ts | 2 +- 8 files changed, 58 insertions(+), 58 deletions(-) create mode 100644 src/app/layout/blocks/raw-html/raw-html-block.component.spec.ts create mode 100644 src/app/layout/blocks/raw-html/raw-html-block.component.ts create mode 100644 src/app/layout/blocks/raw-html/raw-html-block.html delete mode 100644 src/app/layout/blocks/raw-html/raw-html.component.spec.ts delete mode 100644 src/app/layout/blocks/raw-html/raw-html.component.ts delete mode 100644 src/app/layout/blocks/raw-html/raw-html.html diff --git a/src/app/layout/blocks/raw-html/index.ts b/src/app/layout/blocks/raw-html/index.ts index 477ef35..838cfba 100644 --- a/src/app/layout/blocks/raw-html/index.ts +++ b/src/app/layout/blocks/raw-html/index.ts @@ -1,2 +1,2 @@ /* Module Index Entry - generated using the script npm run generate-index */ -export * from "./raw-html.component"; +export * from "./raw-html-block.component"; diff --git a/src/app/layout/blocks/raw-html/raw-html-block.component.spec.ts b/src/app/layout/blocks/raw-html/raw-html-block.component.spec.ts new file mode 100644 index 0000000..eddbd7e --- /dev/null +++ b/src/app/layout/blocks/raw-html/raw-html-block.component.spec.ts @@ -0,0 +1,36 @@ +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; +import {Component} from 'ng-forward'; + +import {RawHTMLBlockComponent} from './raw-html-block.component'; + +const tcb = new TestComponentBuilder(); + +const htmlTemplate: string = ''; + +describe("Components", () => { + + describe("Raw Html Block Component", () => { + + beforeEach(angular.mock.module("templates")); + beforeEach(angular.mock.module("ngSanitize")); + + it("display html stored in block settings", done => { + + @Component({ + selector: 'test-container-component', + template: htmlTemplate, + directives: [RawHTMLBlockComponent], + }) + class CustomBlockType { + block: any = { settings: { html: 'block content' } }; + owner: any = { name: 'profile-name' }; + } + tcb.createAsync(CustomBlockType).then(fixture => { + expect(fixture.debugElement.query(".raw-html-block em").text().trim()).toEqual('block content'); + done(); + }); + }); + + }); + +}); diff --git a/src/app/layout/blocks/raw-html/raw-html-block.component.ts b/src/app/layout/blocks/raw-html/raw-html-block.component.ts new file mode 100644 index 0000000..4636f87 --- /dev/null +++ b/src/app/layout/blocks/raw-html/raw-html-block.component.ts @@ -0,0 +1,18 @@ +import {Component, Input} from "ng-forward"; + +@Component({ + selector: "noosfero-raw-html-block", + templateUrl: 'app/layout/blocks/raw-html/raw-html-block.html' +}) + +export class RawHTMLBlockComponent { + + @Input() block: any; + @Input() owner: any; + + html: string; + + ngOnInit() { + this.html = this.block.settings.html; + } +} diff --git a/src/app/layout/blocks/raw-html/raw-html-block.html b/src/app/layout/blocks/raw-html/raw-html-block.html new file mode 100644 index 0000000..af6cf33 --- /dev/null +++ b/src/app/layout/blocks/raw-html/raw-html-block.html @@ -0,0 +1,2 @@ +
+
diff --git a/src/app/layout/blocks/raw-html/raw-html.component.spec.ts b/src/app/layout/blocks/raw-html/raw-html.component.spec.ts deleted file mode 100644 index 7ec81ed..0000000 --- a/src/app/layout/blocks/raw-html/raw-html.component.spec.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; -import {Component} from 'ng-forward'; - -import {RawHTMLBlockComponent} from './raw-html.component'; - -const tcb = new TestComponentBuilder(); - -const htmlTemplate: string = ''; - -describe("Components", () => { - - describe("Raw Html Block Component", () => { - - beforeEach(angular.mock.module("templates")); - beforeEach(angular.mock.module("ngSanitize")); - - it("display html stored in block settings", done => { - - @Component({ - selector: 'test-container-component', - template: htmlTemplate, - directives: [RawHTMLBlockComponent], - }) - class CustomBlockType { - block: any = { settings: { html: 'block content' } }; - owner: any = { name: 'profile-name' }; - } - tcb.createAsync(CustomBlockType).then(fixture => { - expect(fixture.debugElement.query(".raw-html-block em").text().trim()).toEqual('block content'); - done(); - }); - }); - - }); - -}); diff --git a/src/app/layout/blocks/raw-html/raw-html.component.ts b/src/app/layout/blocks/raw-html/raw-html.component.ts deleted file mode 100644 index b320d98..0000000 --- a/src/app/layout/blocks/raw-html/raw-html.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, Input} from "ng-forward"; - -@Component({ - selector: "noosfero-raw-htmlblock", - templateUrl: 'app/layout/blocks/raw-html/raw-html.html' -}) - -export class RawHTMLBlockComponent { - - @Input() block: any; - @Input() owner: any; - - html: string; - - ngOnInit() { - this.html = this.block.settings.html; - } -} diff --git a/src/app/layout/blocks/raw-html/raw-html.html b/src/app/layout/blocks/raw-html/raw-html.html deleted file mode 100644 index af6cf33..0000000 --- a/src/app/layout/blocks/raw-html/raw-html.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 1c6cc2c..8989b88 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -13,7 +13,7 @@ import {PeopleBlockComponent} from "../layout/blocks/people/people-block.compone import {LinkListBlockComponent} from "./../layout/blocks/link-list/link-list-block.component"; import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/recent-documents.component"; import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component"; -import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html.component"; +import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component"; import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component"; -- libgit2 0.21.2