boxes.component.spec.ts
1.92 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import {Component} from 'ng-forward';
import {BoxesComponent} from './boxes.component';
import {
createComponentFromClass,
quickCreateComponent,
provideEmptyObjects,
createProviderToValue,
provideFilters
} from "../../../spec/helpers";
// this htmlTemplate will be re-used between the container components in this spec file
const htmlTemplate: string = '<noosfero-boxes [boxes]="ctrl.boxes" [owner]="ctrl.profile"></noosfero-blog>';
describe("Boxes Component", () => {
beforeEach(() => {
angular.mock.module("templates");
});
@Component({
selector: 'test-container-component',
template: htmlTemplate,
directives: [BoxesComponent],
providers: []
})
class BoxesContainerComponent {
boxes: noosfero.Box[] = [
{ id: 1, position: 1 },
{ id: 2, position: 2 }
];
owner: noosfero.Profile = <noosfero.Profile> {
id: 1,
identifier: 'profile-name',
type: 'Person'
};
}
it("renders boxes into a container", (done: Function) => {
createComponentFromClass(BoxesContainerComponent).then((fixture) => {
let boxesHtml = fixture.debugElement;
expect(boxesHtml.query('div.col-md-7').length).toEqual(1);
expect(boxesHtml.query('div.col-md-2-5').length).toEqual(1);
done();
});
});
it("check the boxes order", (done: Function) => {
createComponentFromClass(BoxesContainerComponent).then((fixture) => {
let boxesComponent: BoxesComponent = fixture.debugElement.componentViewChildren[0].componentInstance;
let boxesContainer: BoxesContainerComponent = fixture.componentInstance;
expect(boxesComponent.boxesOrder(boxesContainer.boxes[0])).toEqual(1);
expect(boxesComponent.boxesOrder(boxesContainer.boxes[1])).toEqual(0);
done();
});
});
});