From 34d5ef654b304c628b527ad5eab0aa598768f08a Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Tue, 10 May 2016 09:11:55 -0300 Subject: [PATCH] refactoring link list block --- src/app/layout/blocks/link-list/index.ts | 2 +- src/app/layout/blocks/link-list/link-list-block.component.spec.ts | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/app/layout/blocks/link-list/link-list-block.component.ts | 20 ++++++++++++++++++++ src/app/layout/blocks/link-list/link-list-block.html | 7 +++++++ src/app/layout/blocks/link-list/link-list-block.scss | 34 ++++++++++++++++++++++++++++++++++ src/app/layout/blocks/link-list/link-list.component.spec.ts | 65 ----------------------------------------------------------------- src/app/layout/blocks/link-list/link-list.component.ts | 20 -------------------- src/app/layout/blocks/link-list/link-list.html | 7 ------- src/app/layout/blocks/link-list/link-list.scss | 34 ---------------------------------- src/app/main/main.component.ts | 2 +- 10 files changed, 128 insertions(+), 128 deletions(-) create mode 100644 src/app/layout/blocks/link-list/link-list-block.component.spec.ts create mode 100644 src/app/layout/blocks/link-list/link-list-block.component.ts create mode 100644 src/app/layout/blocks/link-list/link-list-block.html create mode 100644 src/app/layout/blocks/link-list/link-list-block.scss delete mode 100644 src/app/layout/blocks/link-list/link-list.component.spec.ts delete mode 100644 src/app/layout/blocks/link-list/link-list.component.ts delete mode 100644 src/app/layout/blocks/link-list/link-list.html delete mode 100644 src/app/layout/blocks/link-list/link-list.scss diff --git a/src/app/layout/blocks/link-list/index.ts b/src/app/layout/blocks/link-list/index.ts index 765aba8..4c2ccd3 100644 --- a/src/app/layout/blocks/link-list/index.ts +++ b/src/app/layout/blocks/link-list/index.ts @@ -1,2 +1,2 @@ /* Module Index Entry - generated using the script npm run generate-index */ -export * from "./link-list.component"; +export * from "./link-list-block.component"; diff --git a/src/app/layout/blocks/link-list/link-list-block.component.spec.ts b/src/app/layout/blocks/link-list/link-list-block.component.spec.ts new file mode 100644 index 0000000..594307d --- /dev/null +++ b/src/app/layout/blocks/link-list/link-list-block.component.spec.ts @@ -0,0 +1,65 @@ +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; +import {Pipe, Input, provide, Component} from 'ng-forward'; +import {provideFilters} from '../../../../spec/helpers'; + +import {LinkListBlockComponent} from './link-list-block.component'; + +const tcb = new TestComponentBuilder(); + +const htmlTemplate: string = ''; + + +describe("Components", () => { + + describe("Link List Block Component", () => { + + beforeEach(angular.mock.module("templates")); + + it("receives the block and the owner as inputs", done => { + + // Creating a container component (BlockContainerComponent) to include + // the component under test (Block) + @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [LinkListBlockComponent] }) + class BlockContainerComponent { + block = { type: 'Block' }; + owner = { name: 'profile-name' }; + constructor() { + } + } + + // uses the TestComponentBuilder instance to initialize the component + // .overrideView(LinkListBlock, { template: 'asdasdasd', pipes: [NoosferoTemplate] }) + tcb.createAsync(BlockContainerComponent).then(fixture => { + // and here we can inspect and run the test assertions + let myComponent: LinkListBlockComponent = fixture.componentInstance; + + // assure the block object inside the Block matches + // the provided through the parent component + expect(myComponent.block.type).toEqual("Block"); + expect(myComponent.owner.name).toEqual("profile-name"); + done(); + }); + }); + + + it("display links stored in block settings", done => { + + @Component({ + selector: 'test-container-component', + template: htmlTemplate, + directives: [LinkListBlockComponent], + providers: provideFilters("noosferoTemplateFilter") + }) + class CustomBlockType { + block: any = { settings: { links: [{ name: 'link1', address: 'address1' }, { name: 'link2', address: 'address2' }] } }; + owner: any = { name: 'profile-name' }; + } + tcb.createAsync(CustomBlockType).then(fixture => { + expect(fixture.debugElement.queryAll(".link-list-block a").length).toEqual(2); + done(); + }); + }); + + }); + +}); diff --git a/src/app/layout/blocks/link-list/link-list-block.component.ts b/src/app/layout/blocks/link-list/link-list-block.component.ts new file mode 100644 index 0000000..238aee8 --- /dev/null +++ b/src/app/layout/blocks/link-list/link-list-block.component.ts @@ -0,0 +1,20 @@ +import {Component, Input} from "ng-forward"; + +@Component({ + selector: "noosfero-link-list-block", + templateUrl: "app/layout/blocks/link-list/link-list-block.html" +}) +export class LinkListBlockComponent { + + @Input() block: any; + @Input() owner: any; + + links: any; + + ngOnInit() { + if (this.block && this.block.settings) { + this.links = this.block.settings.links; + } + } + +} diff --git a/src/app/layout/blocks/link-list/link-list-block.html b/src/app/layout/blocks/link-list/link-list-block.html new file mode 100644 index 0000000..17db1db --- /dev/null +++ b/src/app/layout/blocks/link-list/link-list-block.html @@ -0,0 +1,7 @@ + diff --git a/src/app/layout/blocks/link-list/link-list-block.scss b/src/app/layout/blocks/link-list/link-list-block.scss new file mode 100644 index 0000000..bd60824 --- /dev/null +++ b/src/app/layout/blocks/link-list/link-list-block.scss @@ -0,0 +1,34 @@ +.icon-event { + @extend .fa-calendar; +} +.icon-photos { + @extend .fa-photo; +} +.icon-edit { + @extend .fa-edit; +} +.icon-ok { + @extend .fa-check; +} +.icon-send { + @extend .fa-send-o; +} +.icon-menu-people { + @extend .fa-user; +} +.icon-forum { + @extend .fa-users; +} +.icon-new { + @extend .fa-file-o; +} +.icon-save { + @extend .fa-save; +} + +.link-list-block { + a i { + line-height: 25px; + color: #949494; + } +} diff --git a/src/app/layout/blocks/link-list/link-list.component.spec.ts b/src/app/layout/blocks/link-list/link-list.component.spec.ts deleted file mode 100644 index 0de73a8..0000000 --- a/src/app/layout/blocks/link-list/link-list.component.spec.ts +++ /dev/null @@ -1,65 +0,0 @@ -import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder'; -import {Pipe, Input, provide, Component} from 'ng-forward'; -import {provideFilters} from '../../../../spec/helpers'; - -import {LinkListBlockComponent} from './link-list.component'; - -const tcb = new TestComponentBuilder(); - -const htmlTemplate: string = ''; - - -describe("Components", () => { - - describe("Link List Block Component", () => { - - beforeEach(angular.mock.module("templates")); - - it("receives the block and the owner as inputs", done => { - - // Creating a container component (BlockContainerComponent) to include - // the component under test (Block) - @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [LinkListBlockComponent] }) - class BlockContainerComponent { - block = { type: 'Block' }; - owner = { name: 'profile-name' }; - constructor() { - } - } - - // uses the TestComponentBuilder instance to initialize the component - // .overrideView(LinkListBlock, { template: 'asdasdasd', pipes: [NoosferoTemplate] }) - tcb.createAsync(BlockContainerComponent).then(fixture => { - // and here we can inspect and run the test assertions - let myComponent: LinkListBlockComponent = fixture.componentInstance; - - // assure the block object inside the Block matches - // the provided through the parent component - expect(myComponent.block.type).toEqual("Block"); - expect(myComponent.owner.name).toEqual("profile-name"); - done(); - }); - }); - - - it("display links stored in block settings", done => { - - @Component({ - selector: 'test-container-component', - template: htmlTemplate, - directives: [LinkListBlockComponent], - providers: provideFilters("noosferoTemplateFilter") - }) - class CustomBlockType { - block: any = { settings: { links: [{ name: 'link1', address: 'address1' }, { name: 'link2', address: 'address2' }] } }; - owner: any = { name: 'profile-name' }; - } - tcb.createAsync(CustomBlockType).then(fixture => { - expect(fixture.debugElement.queryAll(".link-list-block a").length).toEqual(2); - done(); - }); - }); - - }); - -}); \ No newline at end of file diff --git a/src/app/layout/blocks/link-list/link-list.component.ts b/src/app/layout/blocks/link-list/link-list.component.ts deleted file mode 100644 index fa1ea80..0000000 --- a/src/app/layout/blocks/link-list/link-list.component.ts +++ /dev/null @@ -1,20 +0,0 @@ -import {Component, Input} from "ng-forward"; - -@Component({ - selector: "noosfero-link-list-block", - templateUrl: "app/layout/blocks/link-list/link-list.html" -}) -export class LinkListBlockComponent { - - @Input() block: any; - @Input() owner: any; - - links: any; - - ngOnInit() { - if (this.block && this.block.settings) { - this.links = this.block.settings.links; - } - } - -} diff --git a/src/app/layout/blocks/link-list/link-list.html b/src/app/layout/blocks/link-list/link-list.html deleted file mode 100644 index 17db1db..0000000 --- a/src/app/layout/blocks/link-list/link-list.html +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/src/app/layout/blocks/link-list/link-list.scss b/src/app/layout/blocks/link-list/link-list.scss deleted file mode 100644 index bd60824..0000000 --- a/src/app/layout/blocks/link-list/link-list.scss +++ /dev/null @@ -1,34 +0,0 @@ -.icon-event { - @extend .fa-calendar; -} -.icon-photos { - @extend .fa-photo; -} -.icon-edit { - @extend .fa-edit; -} -.icon-ok { - @extend .fa-check; -} -.icon-send { - @extend .fa-send-o; -} -.icon-menu-people { - @extend .fa-user; -} -.icon-forum { - @extend .fa-users; -} -.icon-new { - @extend .fa-file-o; -} -.icon-save { - @extend .fa-save; -} - -.link-list-block { - a i { - line-height: 25px; - color: #949494; - } -} diff --git a/src/app/main/main.component.ts b/src/app/main/main.component.ts index 1285e8a..6b97764 100644 --- a/src/app/main/main.component.ts +++ b/src/app/main/main.component.ts @@ -10,7 +10,7 @@ import {BlockComponent} from "../layout/blocks/block.component"; import {EnvironmentComponent} from "../environment/environment.component"; import {EnvironmentHomeComponent} from "../environment/environment-home.component"; import {PeopleBlockComponent} from "../layout/blocks/people-block/people-block.component"; -import {LinkListBlockComponent} from "./../layout/blocks/link-list/link-list.component"; +import {LinkListBlockComponent} from "./../layout/blocks/link-list/link-list-block.component"; import {RecentDocumentsBlockComponent} from "../layout/blocks/recent-documents/recent-documents.component"; import {ProfileImageBlockComponent} from "../layout/blocks/profile-image-block/profile-image-block.component"; import {RawHTMLBlockComponent} from "../layout/blocks/raw-html/raw-html.component"; -- libgit2 0.21.2