From e7ede5b436d3f1892b66b34c5918758e222e359f Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Fri, 11 Mar 2016 03:31:22 -0300 Subject: [PATCH] new block: RawHtml --- src/app/components/noosfero-blocks/raw-html/raw-html.component.spec.ts | 38 ++++++++++++++++++++++++++++++++++++++ src/app/components/noosfero-blocks/raw-html/raw-html.component.ts | 18 ++++++++++++++++++ src/app/components/noosfero-blocks/raw-html/raw-html.html | 2 ++ 3 files changed, 58 insertions(+), 0 deletions(-) create mode 100644 src/app/components/noosfero-blocks/raw-html/raw-html.component.spec.ts create mode 100644 src/app/components/noosfero-blocks/raw-html/raw-html.component.ts create mode 100644 src/app/components/noosfero-blocks/raw-html/raw-html.html diff --git a/src/app/components/noosfero-blocks/raw-html/raw-html.component.spec.ts b/src/app/components/noosfero-blocks/raw-html/raw-html.component.spec.ts new file mode 100644 index 0000000..45da1df --- /dev/null +++ b/src/app/components/noosfero-blocks/raw-html/raw-html.component.spec.ts @@ -0,0 +1,38 @@ +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; +import {Component} from 'ng-forward'; + +import {RawHtmlBlock} 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("noosferoApp", ($translateProvider: angular.translate.ITranslateProvider) => { + $translateProvider.translations('en', {}); + })); + + it("display html stored in block settings", done => { + + @Component({ + selector: 'test-container-component', + template: htmlTemplate, + directives: [RawHtmlBlock], + }) + 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/components/noosfero-blocks/raw-html/raw-html.component.ts b/src/app/components/noosfero-blocks/raw-html/raw-html.component.ts new file mode 100644 index 0000000..d3723c3 --- /dev/null +++ b/src/app/components/noosfero-blocks/raw-html/raw-html.component.ts @@ -0,0 +1,18 @@ +import {Component, Input} from "ng-forward"; + +@Component({ + selector: "noosfero-raw-html-block", + templateUrl: 'app/components/noosfero-blocks/raw-html/raw-html.html' +}) + +export class RawHtmlBlock { + + @Input() block: any; + @Input() owner: any; + + html: string; + + ngOnInit() { + this.html = this.block.settings.html; + } +} diff --git a/src/app/components/noosfero-blocks/raw-html/raw-html.html b/src/app/components/noosfero-blocks/raw-html/raw-html.html new file mode 100644 index 0000000..af6cf33 --- /dev/null +++ b/src/app/components/noosfero-blocks/raw-html/raw-html.html @@ -0,0 +1,2 @@ +
+
-- libgit2 0.21.2