Commit da32e0223b6c2bfd9f876d8cdbe43a1e3ac9b7a3
1 parent
56073cfd
Exists in
master
and in
26 other branches
refactoring raw html block
Showing
8 changed files
with
58 additions
and
58 deletions
Show diff stats
src/app/layout/blocks/raw-html/index.ts
src/app/layout/blocks/raw-html/raw-html-block.component.spec.ts
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | ||
2 | +import {Component} from 'ng-forward'; | ||
3 | + | ||
4 | +import {RawHTMLBlockComponent} from './raw-html-block.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("ngSanitize")); | ||
16 | + | ||
17 | + it("display html stored in block settings", done => { | ||
18 | + | ||
19 | + @Component({ | ||
20 | + selector: 'test-container-component', | ||
21 | + template: htmlTemplate, | ||
22 | + directives: [RawHTMLBlockComponent], | ||
23 | + }) | ||
24 | + class CustomBlockType { | ||
25 | + block: any = { settings: { html: '<em>block content</em>' } }; | ||
26 | + owner: any = { name: 'profile-name' }; | ||
27 | + } | ||
28 | + tcb.createAsync(CustomBlockType).then(fixture => { | ||
29 | + expect(fixture.debugElement.query(".raw-html-block em").text().trim()).toEqual('block content'); | ||
30 | + done(); | ||
31 | + }); | ||
32 | + }); | ||
33 | + | ||
34 | + }); | ||
35 | + | ||
36 | +}); |
src/app/layout/blocks/raw-html/raw-html-block.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/layout/blocks/raw-html/raw-html-block.html' | ||
6 | +}) | ||
7 | + | ||
8 | +export class RawHTMLBlockComponent { | ||
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/layout/blocks/raw-html/raw-html.component.spec.ts
@@ -1,36 +0,0 @@ | @@ -1,36 +0,0 @@ | ||
1 | -import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; | ||
2 | -import {Component} from 'ng-forward'; | ||
3 | - | ||
4 | -import {RawHTMLBlockComponent} from './raw-html.component'; | ||
5 | - | ||
6 | -const tcb = new TestComponentBuilder(); | ||
7 | - | ||
8 | -const htmlTemplate: string = '<noosfero-raw-htmlblock [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-raw-htmlblock>'; | ||
9 | - | ||
10 | -describe("Components", () => { | ||
11 | - | ||
12 | - describe("Raw Html Block Component", () => { | ||
13 | - | ||
14 | - beforeEach(angular.mock.module("templates")); | ||
15 | - beforeEach(angular.mock.module("ngSanitize")); | ||
16 | - | ||
17 | - it("display html stored in block settings", done => { | ||
18 | - | ||
19 | - @Component({ | ||
20 | - selector: 'test-container-component', | ||
21 | - template: htmlTemplate, | ||
22 | - directives: [RawHTMLBlockComponent], | ||
23 | - }) | ||
24 | - class CustomBlockType { | ||
25 | - block: any = { settings: { html: '<em>block content</em>' } }; | ||
26 | - owner: any = { name: 'profile-name' }; | ||
27 | - } | ||
28 | - tcb.createAsync(CustomBlockType).then(fixture => { | ||
29 | - expect(fixture.debugElement.query(".raw-html-block em").text().trim()).toEqual('block content'); | ||
30 | - done(); | ||
31 | - }); | ||
32 | - }); | ||
33 | - | ||
34 | - }); | ||
35 | - | ||
36 | -}); |
src/app/layout/blocks/raw-html/raw-html.component.ts
@@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
1 | -import {Component, Input} from "ng-forward"; | ||
2 | - | ||
3 | -@Component({ | ||
4 | - selector: "noosfero-raw-htmlblock", | ||
5 | - templateUrl: 'app/layout/blocks/raw-html/raw-html.html' | ||
6 | -}) | ||
7 | - | ||
8 | -export class RawHTMLBlockComponent { | ||
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/layout/blocks/raw-html/raw-html.html
src/app/main/main.component.ts
@@ -13,7 +13,7 @@ import {PeopleBlockComponent} from "../layout/blocks/people/people-block.compone | @@ -13,7 +13,7 @@ import {PeopleBlockComponent} from "../layout/blocks/people/people-block.compone | ||
13 | import {LinkListBlockComponent} from "./../layout/blocks/link-list/link-list-block.component"; | 13 | import {LinkListBlockComponent} from "./../layout/blocks/link-list/link-list-block.component"; |
14 | import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/recent-documents.component"; | 14 | import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/recent-documents.component"; |
15 | import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component"; | 15 | import {ProfileImageBlockComponent} from "../layout/blocks/profile-image/profile-image-block.component"; |
16 | -import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html.component"; | 16 | +import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html-block.component"; |
17 | 17 | ||
18 | import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; | 18 | import {MembersBlockComponent} from "./../layout/blocks/members/members-block.component"; |
19 | import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component"; | 19 | import {CommunitiesBlockComponent} from "./../layout/blocks/communities/communities-block.component"; |