statistics-block.component.spec.ts
2.5 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
import {provide} from 'ng-forward';
import {ComponentTestHelper, createClass} from './../../../../spec/component-test-helper';
import {StatisticsBlockComponent} from './statistics-block.component';
import * as helpers from "../../../../spec/helpers";
const htmlTemplate: string = '<noosfero-statistics-block [block]="ctrl.block" [owner]="ctrl.owner"></noosfero-statistics-block>';
describe("Components", () => {
describe("Statistics Block Component", () => {
let helper: ComponentTestHelper<StatisticsBlockComponent>;
beforeEach(angular.mock.module("templates"));
beforeEach((done) => {
let articleService: any = helpers.mocks.articleService;
let blockService: any = jasmine.createSpyObj("blockService", ["getBlock"]);
let cls = createClass({
template: htmlTemplate,
directives: [StatisticsBlockComponent],
providers: [
provide('ArticleService', { useValue: articleService }),
provide('BlockService', { useValue: blockService })
].concat(helpers.provideFilters("translateFilter")),
properties: {
block: {
statistics: [
{
name: "users",
display: true,
quantity: 10
},
{
name: "communities",
display: true,
quantity: 20
},
{
name: "hits",
display: false,
quantity: null
}
]
}
}
});
helper = new ComponentTestHelper<StatisticsBlockComponent>(cls, done);
});
it("shows statistics marked with display equals 'true'", () => {
expect(helper.debugElement.queryAll("li.statistic").length).toEqual(2);
expect(helper.debugElement.query("span.users").text()).toEqual("10");
expect(helper.debugElement.query("span.communities").text()).toEqual("20");
});
it("does not shows statistics marked with display equals 'false'", () => {
expect(helper.debugElement.queryAll("span.hits").length).toEqual(0);
});
});
});