Commit d6dcf19b42f030148d63b04b46f8ba87ec07af9c

Authored by ABNER SILVA DE OLIVEIRA
2 parents babe9d57 4aa998ad
Exists in master and in 1 other branch dev-fixes

Merge branch 'ngforward' of softwarepublico.gov.br:noosfero-themes/angular-theme into ngforward

@@ -6,6 +6,7 @@ coverage/ @@ -6,6 +6,7 @@ coverage/
6 .tmp/ 6 .tmp/
7 dist/ 7 dist/
8 src/noosfero.js* 8 src/noosfero.js*
9 -src/commons.js  
10 -src/noosfero-specs.js 9 +src/commons.js*
  10 +src/noosfero-specs.js*
11 typings 11 typings
  12 +npm-debug.log
src/app/components/noosfero-blocks/link-list/link-list.component.spec.ts
1 import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; 1 import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder';
2 import {Pipe, Input, provide, Component} from 'ng-forward'; 2 import {Pipe, Input, provide, Component} from 'ng-forward';
  3 +import {provideFilters} from '../../../../spec/helpers';
3 4
4 import {LinkListBlock} from './link-list.component'; 5 import {LinkListBlock} from './link-list.component';
5 6
@@ -41,21 +42,17 @@ describe("Link List Block Component", () => { @@ -41,21 +42,17 @@ describe("Link List Block Component", () => {
41 42
42 it("display links stored in block settings", done => { 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 class CustomBlockType { 51 class CustomBlockType {
53 block: any = { settings: { links: [{ name: 'link1', address: 'address1' }, { name: 'link2', address: 'address2' }] } }; 52 block: any = { settings: { links: [{ name: 'link1', address: 'address1' }, { name: 'link2', address: 'address2' }] } };
54 owner: any = { name: 'profile-name' }; 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 expect(fixture.debugElement.queryAll(".link-list-block a").length).toEqual(2); 56 expect(fixture.debugElement.queryAll(".link-list-block a").length).toEqual(2);
60 done(); 57 done();
61 }); 58 });
src/app/components/noosfero-blocks/link-list/link-list.html
1 <div class="link-list-block"> 1 <div class="link-list-block">
2 <div ng-repeat="link in ctrl.links"> 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 <i class="fa fa-fw icon-{{link.icon}}"></i> <span>{{link.name}}</span> 4 <i class="fa fa-fw icon-{{link.icon}}"></i> <span>{{link.name}}</span>
5 </a> 5 </a>
6 </div> 6 </div>
src/app/components/noosfero-blocks/members-block/members-block.component.spec.ts
@@ -34,15 +34,14 @@ describe(&quot;Members Block Component&quot;, () =&gt; { @@ -34,15 +34,14 @@ describe(&quot;Members Block Component&quot;, () =&gt; {
34 34
35 it("get members of the block owner", done => { 35 it("get members of the block owner", done => {
36 tcb.createAsync(BlockContainerComponent).then(fixture => { 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 done(); 39 done();
40 }); 40 });
41 }); 41 });
42 42
43 it("render the profile image for each member", done => { 43 it("render the profile image for each member", done => {
44 tcb.createAsync(BlockContainerComponent).then(fixture => { 44 tcb.createAsync(BlockContainerComponent).then(fixture => {
45 - let recentDocumentsBlock: MembersBlock = fixture.debugElement.componentViewChildren[0].componentInstance;  
46 fixture.debugElement.getLocal("$rootScope").$apply(); 45 fixture.debugElement.getLocal("$rootScope").$apply();
47 expect(fixture.debugElement.queryAll("noosfero-profile-image").length).toEqual(1); 46 expect(fixture.debugElement.queryAll("noosfero-profile-image").length).toEqual(1);
48 done(); 47 done();
src/app/components/noosfero-blocks/recent-documents/recent-documents.component.spec.ts
1 import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; 1 import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder';
2 import {Provider, Input, provide, Component} from 'ng-forward'; 2 import {Provider, Input, provide, Component} from 'ng-forward';
3 - 3 +import {provideFilters} from '../../../../spec/helpers';
4 import {RecentDocumentsBlock} from './recent-documents.component'; 4 import {RecentDocumentsBlock} from './recent-documents.component';
5 5
6 const htmlTemplate: string = '<noosfero-recent-documents-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-recent-documents-block>'; 6 const htmlTemplate: string = '<noosfero-recent-documents-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-recent-documents-block>';
@@ -13,8 +13,6 @@ describe(&quot;Recent Documents Block Component&quot;, () =&gt; { @@ -13,8 +13,6 @@ describe(&quot;Recent Documents Block Component&quot;, () =&gt; {
13 13
14 let state = jasmine.createSpyObj("state", ["go"]); 14 let state = jasmine.createSpyObj("state", ["go"]);
15 let providers = [ 15 let providers = [
16 - new Provider('truncateFilter', { useValue: () => { } }),  
17 - new Provider('stripTagsFilter', { useValue: () => { } }),  
18 new Provider('$state', { useValue: state }), 16 new Provider('$state', { useValue: state }),
19 new Provider('ArticleService', { 17 new Provider('ArticleService', {
20 useValue: { 18 useValue: {
@@ -23,7 +21,8 @@ describe(&quot;Recent Documents Block Component&quot;, () =&gt; { @@ -23,7 +21,8 @@ describe(&quot;Recent Documents Block Component&quot;, () =&gt; {
23 } 21 }
24 } 22 }
25 }), 23 }),
26 - ]; 24 + ].concat(provideFilters("truncateFilter", "stripTagsFilter"));
  25 +
27 @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [RecentDocumentsBlock], providers: providers }) 26 @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [RecentDocumentsBlock], providers: providers })
28 class BlockContainerComponent { 27 class BlockContainerComponent {
29 block = { type: 'Block', settings: {} }; 28 block = { type: 'Block', settings: {} };
src/app/components/noosfero/noosfero-template.filter.js
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 'use strict'; 2 'use strict';
3 angular 3 angular
4 .module("noosferoApp") 4 .module("noosferoApp")
5 - .filter("noosferoTemplateFilter", function() { 5 + .filter("noosferoTemplate", function() {
6 return function(text, options) { 6 return function(text, options) {
7 for(var option in options) { 7 for(var option in options) {
8 text = text.replace('{'+option+'}', options[option]); 8 text = text.replace('{'+option+'}', options[option]);
src/spec/helpers.ts
1 1
2 import {ngClass, TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder'; 2 import {ngClass, TestComponentBuilder, ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder';
3 import {quickFixture} from 'ng-forward/cjs/tests/utils'; 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,3 +29,10 @@ export function createComponentFromClass(yourClass: ngClass) {
29 return tcb.createAsync(yourClass); 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 +}