main-block.component.spec.ts
1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {TestComponentBuilder} from 'ng-forward/cjs/testing/test-component-builder';
import {Input, provide, Component, StateConfig} from 'ng-forward';
import {MainBlock} from './main-block.component';
import {NoosferoApp} from '../../../index.module';
const tcb = new TestComponentBuilder();
const htmlTemplate: string = '<noosfero-main-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-main-block>';
describe("Main Block Component", () => {
// the karma preprocessor html2js transform the templates html into js files which put
// the templates to the templateCache into the module templates
// we need to load the module templates here as the template for the
// component Block will be load on our tests
beforeEach(angular.mock.module("templates"));
it("check if the main block has a tag with ui-view attribute", done => {
// Creating a container component (BlockContainerComponent) to include
// the component under test (Block)
@Component({ selector: 'test-container-component', template: htmlTemplate, directives: [MainBlock] })
class BlockContainerComponent {
}
// uses the TestComponentBuilder instance to initialize the component
tcb.createAsync(BlockContainerComponent).then(fixture => {
// and here we can inspect and run the test assertions
//let myComponent: MainBlock = fixture.componentInstance;
// assure the block object inside the Block matches
// the provided through the parent component
expect(fixture.debugElement.queryAll('[ui-view="mainBlockContent"]').length).toEqual(1)
done();
});
});
});