Commit e7ede5b436d3f1892b66b34c5918758e222e359f
1 parent
08a6c237
Exists in
master
and in
1 other branch
new block: RawHtml
Showing
3 changed files
with
58 additions
and
0 deletions
Show diff stats
src/app/components/noosfero-blocks/raw-html/raw-html.component.spec.ts
0 → 100644
@@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
1 | +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | ||
2 | +import {Component} from 'ng-forward'; | ||
3 | + | ||
4 | +import {RawHtmlBlock} from './raw-html.component'; | ||
5 | + | ||
6 | +const tcb = new TestComponentBuilder(); | ||
7 | + | ||
8 | +const htmlTemplate: string = '<noosfero-raw-html-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-raw-html-block>'; | ||
9 | + | ||
10 | +describe("Components", () => { | ||
11 | + | ||
12 | + describe("Raw Html Block Component", () => { | ||
13 | + | ||
14 | + beforeEach(angular.mock.module("templates")); | ||
15 | + beforeEach(angular.mock.module("noosferoApp", ($translateProvider: angular.translate.ITranslateProvider) => { | ||
16 | + $translateProvider.translations('en', {}); | ||
17 | + })); | ||
18 | + | ||
19 | + it("display html stored in block settings", done => { | ||
20 | + | ||
21 | + @Component({ | ||
22 | + selector: 'test-container-component', | ||
23 | + template: htmlTemplate, | ||
24 | + directives: [RawHtmlBlock], | ||
25 | + }) | ||
26 | + class CustomBlockType { | ||
27 | + block: any = { settings: { html: '<em>block content</em>' } }; | ||
28 | + owner: any = { name: 'profile-name' }; | ||
29 | + } | ||
30 | + tcb.createAsync(CustomBlockType).then(fixture => { | ||
31 | + expect(fixture.debugElement.query(".raw-html-block em").text().trim()).toEqual('block content'); | ||
32 | + done(); | ||
33 | + }); | ||
34 | + }); | ||
35 | + | ||
36 | + }); | ||
37 | + | ||
38 | +}); |
src/app/components/noosfero-blocks/raw-html/raw-html.component.ts
0 → 100644
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +import {Component, Input} from "ng-forward"; | ||
2 | + | ||
3 | +@Component({ | ||
4 | + selector: "noosfero-raw-html-block", | ||
5 | + templateUrl: 'app/components/noosfero-blocks/raw-html/raw-html.html' | ||
6 | +}) | ||
7 | + | ||
8 | +export class RawHtmlBlock { | ||
9 | + | ||
10 | + @Input() block: any; | ||
11 | + @Input() owner: any; | ||
12 | + | ||
13 | + html: string; | ||
14 | + | ||
15 | + ngOnInit() { | ||
16 | + this.html = this.block.settings.html; | ||
17 | + } | ||
18 | +} |
src/app/components/noosfero-blocks/raw-html/raw-html.html
0 → 100644