Commit 11081744ad45cddf0900c5c86d75fbccef0474f8

Authored by Leandro Santos
1 parent 34d5ef65

refactoring main block

src/app/layout/blocks/main-block/index.ts
... ... @@ -1,2 +0,0 @@
1   -/* Module Index Entry - generated using the script npm run generate-index */
2   -export * from "./main-block.component";
src/app/layout/blocks/main-block/main-block.component.spec.ts
... ... @@ -1,40 +0,0 @@
1   -import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder';
2   -import {Input, provide, Component, StateConfig} from 'ng-forward';
3   -
4   -import {MainBlockComponent} from './main-block.component';
5   -import {NoosferoApp} from '../../../index.module';
6   -
7   -const tcb = new TestComponentBuilder();
8   -
9   -const htmlTemplate: string = '<noosfero-main-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-main-block>';
10   -
11   -describe("Components", () => {
12   - describe("Main Block Component", () => {
13   -
14   - // the karma preprocessor html2js transform the templates html into js files which put
15   - // the templates to the templateCache into the module templates
16   - // we need to load the module templates here as the template for the
17   - // component Block will be load on our tests
18   - beforeEach(angular.mock.module("templates"));
19   -
20   - it("check if the main block has a tag with ui-view attribute", done => {
21   -
22   - // Creating a container component (BlockContainerComponent) to include
23   - // the component under test (Block)
24   - @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [MainBlockComponent] })
25   - class BlockContainerComponent {
26   - }
27   -
28   - // uses the TestComponentBuilder instance to initialize the component
29   - tcb.createAsync(BlockContainerComponent).then(fixture => {
30   - // and here we can inspect and run the test assertions
31   - // let myComponent: MainBlockComponent = fixture.componentInstance;
32   -
33   - // assure the block object inside the Block matches
34   - // the provided through the parent component
35   - expect(fixture.debugElement.queryAll('[ui-view="mainBlockContent"]').length).toEqual(1);
36   - done();
37   - });
38   - });
39   - });
40   -});
41 0 \ No newline at end of file
src/app/layout/blocks/main-block/main-block.component.ts
... ... @@ -1,10 +0,0 @@
1   -import {Component, Input} from 'ng-forward';
2   -import {BlockComponent} from '../block.component';
3   -
4   -@Component({
5   - selector: 'noosfero-main-block',
6   - templateUrl: 'app/layout/blocks/main-block/main-block.html'
7   -})
8   -export class MainBlockComponent {
9   -
10   -}
src/app/layout/blocks/main-block/main-block.html
... ... @@ -1 +0,0 @@
1   -<div ui-view="mainBlockContent" autoscroll></div>
src/app/layout/blocks/main/index.ts 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +/* Module Index Entry - generated using the script npm run generate-index */
  2 +export * from "./main-block.component";
... ...
src/app/layout/blocks/main/main-block.component.spec.ts 0 → 100644
... ... @@ -0,0 +1,40 @@
  1 +import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder';
  2 +import {Input, provide, Component, StateConfig} from 'ng-forward';
  3 +
  4 +import {MainBlockComponent} from './main-block.component';
  5 +import {NoosferoApp} from '../../../index.module';
  6 +
  7 +const tcb = new TestComponentBuilder();
  8 +
  9 +const htmlTemplate: string = '<noosfero-main-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-main-block>';
  10 +
  11 +describe("Components", () => {
  12 + describe("Main Block Component", () => {
  13 +
  14 + // the karma preprocessor html2js transform the templates html into js files which put
  15 + // the templates to the templateCache into the module templates
  16 + // we need to load the module templates here as the template for the
  17 + // component Block will be load on our tests
  18 + beforeEach(angular.mock.module("templates"));
  19 +
  20 + it("check if the main block has a tag with ui-view attribute", done => {
  21 +
  22 + // Creating a container component (BlockContainerComponent) to include
  23 + // the component under test (Block)
  24 + @Component({ selector: 'test-container-component', template: htmlTemplate, directives: [MainBlockComponent] })
  25 + class BlockContainerComponent {
  26 + }
  27 +
  28 + // uses the TestComponentBuilder instance to initialize the component
  29 + tcb.createAsync(BlockContainerComponent).then(fixture => {
  30 + // and here we can inspect and run the test assertions
  31 + // let myComponent: MainBlockComponent = fixture.componentInstance;
  32 +
  33 + // assure the block object inside the Block matches
  34 + // the provided through the parent component
  35 + expect(fixture.debugElement.queryAll('[ui-view="mainBlockContent"]').length).toEqual(1);
  36 + done();
  37 + });
  38 + });
  39 + });
  40 +});
0 41 \ No newline at end of file
... ...
src/app/layout/blocks/main/main-block.component.ts 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +import {Component, Input} from 'ng-forward';
  2 +import {BlockComponent} from '../block.component';
  3 +
  4 +@Component({
  5 + selector: 'noosfero-main-block',
  6 + templateUrl: 'app/layout/blocks/main/main-block.html'
  7 +})
  8 +export class MainBlockComponent {
  9 +
  10 +}
... ...
src/app/layout/blocks/main/main-block.html 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<div ui-view="mainBlockContent" autoscroll></div>
... ...
src/app/main/main.component.ts
... ... @@ -31,7 +31,7 @@ import {Navbar} from &quot;../layout/navbar/navbar&quot;;
31 31  
32 32 import {SidebarComponent} from "../layout/sidebar/sidebar.component";
33 33  
34   -import {MainBlockComponent} from "../layout/blocks/main-block/main-block.component";
  34 +import {MainBlockComponent} from "../layout/blocks/main/main-block.component";
35 35 import {HtmlEditorComponent} from "../shared/components/html-editor/html-editor.component";
36 36  
37 37  
... ...