Commit d6dcf19b42f030148d63b04b46f8ba87ec07af9c
Exists in
master
and in
35 other branches
Merge branch 'ngforward' of softwarepublico.gov.br:noosfero-themes/angular-theme into ngforward
Showing
7 changed files
with
26 additions
and
23 deletions
Show diff stats
.gitignore
src/app/components/noosfero-blocks/link-list/link-list.component.spec.ts
1 | 1 | import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; |
2 | 2 | import {Pipe, Input, provide, Component} from 'ng-forward'; |
3 | +import {provideFilters} from '../../../../spec/helpers'; | |
3 | 4 | |
4 | 5 | import {LinkListBlock} from './link-list.component'; |
5 | 6 | |
... | ... | @@ -41,21 +42,17 @@ describe("Link List Block Component", () => { |
41 | 42 | |
42 | 43 | it("display links stored in block settings", done => { |
43 | 44 | |
44 | - @Pipe('noosferoTemplateFilter') | |
45 | - class NoosferoTemplateFilter { | |
46 | - transform(input: any, changeTo: any) { | |
47 | - return input; | |
48 | - } | |
49 | - } | |
50 | - | |
51 | - @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [LinkListBlock] }) | |
45 | + @Component({ | |
46 | + selector: 'test-container-component', | |
47 | + template: htmlTemplate, | |
48 | + directives: [LinkListBlock], | |
49 | + providers: provideFilters("noosferoTemplateFilter") | |
50 | + }) | |
52 | 51 | class CustomBlockType { |
53 | 52 | block: any = { settings: { links: [{ name: 'link1', address: 'address1' }, { name: 'link2', address: 'address2' }] } }; |
54 | 53 | owner: any = { name: 'profile-name' }; |
55 | - constructor() { | |
56 | - } | |
57 | 54 | } |
58 | - tcb.overrideView(LinkListBlock, { templateUrl: "app/components/noosfero-blocks/link-list/link-list.html", pipes: [NoosferoTemplateFilter] }).createAsync(CustomBlockType).then(fixture => { | |
55 | + tcb.createAsync(CustomBlockType).then(fixture => { | |
59 | 56 | expect(fixture.debugElement.queryAll(".link-list-block a").length).toEqual(2); |
60 | 57 | done(); |
61 | 58 | }); | ... | ... |
src/app/components/noosfero-blocks/link-list/link-list.html
1 | 1 | <div class="link-list-block"> |
2 | 2 | <div ng-repeat="link in ctrl.links"> |
3 | - <a ng-href="{{link.address | noosferoTemplateFilter:{profile: ctrl.owner.identifier} }}"> | |
3 | + <a ng-href="{{link.address | noosferoTemplate:{profile: ctrl.owner.identifier} }}"> | |
4 | 4 | <i class="fa fa-fw icon-{{link.icon}}"></i> <span>{{link.name}}</span> |
5 | 5 | </a> |
6 | 6 | </div> | ... | ... |
src/app/components/noosfero-blocks/members-block/members-block.component.spec.ts
... | ... | @@ -34,15 +34,14 @@ describe("Members Block Component", () => { |
34 | 34 | |
35 | 35 | it("get members of the block owner", done => { |
36 | 36 | tcb.createAsync(BlockContainerComponent).then(fixture => { |
37 | - let recentDocumentsBlock: MembersBlock = fixture.debugElement.componentViewChildren[0].componentInstance; | |
38 | - expect(recentDocumentsBlock.members).toEqual([{ identifier: "person1" }]); | |
37 | + let block: MembersBlock = fixture.debugElement.componentViewChildren[0].componentInstance; | |
38 | + expect(block.members).toEqual([{ identifier: "person1" }]); | |
39 | 39 | done(); |
40 | 40 | }); |
41 | 41 | }); |
42 | 42 | |
43 | 43 | it("render the profile image for each member", done => { |
44 | 44 | tcb.createAsync(BlockContainerComponent).then(fixture => { |
45 | - let recentDocumentsBlock: MembersBlock = fixture.debugElement.componentViewChildren[0].componentInstance; | |
46 | 45 | fixture.debugElement.getLocal("$rootScope").$apply(); |
47 | 46 | expect(fixture.debugElement.queryAll("noosfero-profile-image").length).toEqual(1); |
48 | 47 | done(); | ... | ... |
src/app/components/noosfero-blocks/recent-documents/recent-documents.component.spec.ts
1 | 1 | import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; |
2 | 2 | import {Provider, Input, provide, Component} from 'ng-forward'; |
3 | - | |
3 | +import {provideFilters} from '../../../../spec/helpers'; | |
4 | 4 | import {RecentDocumentsBlock} from './recent-documents.component'; |
5 | 5 | |
6 | 6 | const htmlTemplate: string = '<noosfero-recent-documents-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-recent-documents-block>'; |
... | ... | @@ -13,8 +13,6 @@ describe("Recent Documents Block Component", () => { |
13 | 13 | |
14 | 14 | let state = jasmine.createSpyObj("state", ["go"]); |
15 | 15 | let providers = [ |
16 | - new Provider('truncateFilter', { useValue: () => { } }), | |
17 | - new Provider('stripTagsFilter', { useValue: () => { } }), | |
18 | 16 | new Provider('$state', { useValue: state }), |
19 | 17 | new Provider('ArticleService', { |
20 | 18 | useValue: { |
... | ... | @@ -23,7 +21,8 @@ describe("Recent Documents Block Component", () => { |
23 | 21 | } |
24 | 22 | } |
25 | 23 | }), |
26 | - ]; | |
24 | + ].concat(provideFilters("truncateFilter", "stripTagsFilter")); | |
25 | + | |
27 | 26 | @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [RecentDocumentsBlock], providers: providers }) |
28 | 27 | class BlockContainerComponent { |
29 | 28 | block = { type: 'Block', settings: {} }; | ... | ... |
src/app/components/noosfero/noosfero-template.filter.js
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | 'use strict'; |
3 | 3 | angular |
4 | 4 | .module("noosferoApp") |
5 | - .filter("noosferoTemplateFilter", function() { | |
5 | + .filter("noosferoTemplate", function() { | |
6 | 6 | return function(text, options) { |
7 | 7 | for(var option in options) { |
8 | 8 | text = text.replace('{'+option+'}', options[option]); | ... | ... |
src/spec/helpers.ts
1 | 1 | |
2 | 2 | import {ngClass, TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; |
3 | 3 | import {quickFixture} from 'ng-forward/cjs/tests/utils'; |
4 | -import {Input, provide, Component} from 'ng-forward'; | |
4 | +import {Provider, Input, provide, Component} from 'ng-forward'; | |
5 | 5 | |
6 | 6 | |
7 | 7 | |
... | ... | @@ -29,3 +29,10 @@ export function createComponentFromClass(yourClass: ngClass) { |
29 | 29 | return tcb.createAsync(yourClass); |
30 | 30 | } |
31 | 31 | |
32 | +export function provideFilters(...filters: string[]) { | |
33 | + let providers: Provider[] = []; | |
34 | + for (var filter of filters) { | |
35 | + providers.push(new Provider(filter, { useValue: () => { } })); | |
36 | + } | |
37 | + return providers; | |
38 | +} | ... | ... |