From 4aa998ad243e8d6e6e1fdaf899b6d39296251e72 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Fri, 4 Mar 2016 14:12:23 -0300 Subject: [PATCH] Create a helper to provide filters to tests --- src/app/components/noosfero-blocks/link-list/link-list.component.spec.ts | 19 ++++++++----------- src/app/components/noosfero-blocks/link-list/link-list.html | 2 +- src/app/components/noosfero-blocks/recent-documents/recent-documents.component.spec.ts | 7 +++---- src/app/components/noosfero/noosfero-template.filter.js | 2 +- src/spec/helpers.ts | 9 ++++++++- 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/app/components/noosfero-blocks/link-list/link-list.component.spec.ts b/src/app/components/noosfero-blocks/link-list/link-list.component.spec.ts index d1395d7..ea13d21 100644 --- a/src/app/components/noosfero-blocks/link-list/link-list.component.spec.ts +++ b/src/app/components/noosfero-blocks/link-list/link-list.component.spec.ts @@ -1,5 +1,6 @@ import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; import {Pipe, Input, provide, Component} from 'ng-forward'; +import {provideFilters} from '../../../../spec/helpers'; import {LinkListBlock} from './link-list.component'; @@ -41,21 +42,17 @@ describe("Link List Block Component", () => { it("display links stored in block settings", done => { - @Pipe('noosferoTemplateFilter') - class NoosferoTemplateFilter { - transform(input: any, changeTo: any) { - return input; - } - } - - @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [LinkListBlock] }) + @Component({ + selector: 'test-container-component', + template: htmlTemplate, + directives: [LinkListBlock], + providers: provideFilters("noosferoTemplateFilter") + }) class CustomBlockType { block: any = { settings: { links: [{ name: 'link1', address: 'address1' }, { name: 'link2', address: 'address2' }] } }; owner: any = { name: 'profile-name' }; - constructor() { - } } - tcb.overrideView(LinkListBlock, { templateUrl: "app/components/noosfero-blocks/link-list/link-list.html", pipes: [NoosferoTemplateFilter] }).createAsync(CustomBlockType).then(fixture => { + tcb.createAsync(CustomBlockType).then(fixture => { expect(fixture.debugElement.queryAll(".link-list-block a").length).toEqual(2); done(); }); diff --git a/src/app/components/noosfero-blocks/link-list/link-list.html b/src/app/components/noosfero-blocks/link-list/link-list.html index f874ad4..17db1db 100644 --- a/src/app/components/noosfero-blocks/link-list/link-list.html +++ b/src/app/components/noosfero-blocks/link-list/link-list.html @@ -1,6 +1,6 @@