Commit 2efd58655e5f7a301ae5f76f335059b5ffa0a866
1 parent
5af8017d
Exists in
master
and in
26 other branches
adding unit test for statistics block
Showing
1 changed file
with
29 additions
and
30 deletions
Show diff stats
src/app/layout/blocks/statistics/statistics-block.component.spec.ts
... | ... | @@ -78,40 +78,39 @@ describe("Components", () => { |
78 | 78 | expect(helper.find('.list-group-item.users').length).toEqual(1, "The statistics-block should have a list item with users class"); |
79 | 79 | }); |
80 | 80 | |
81 | + it("should render the enterprise count information", () => { | |
82 | + expect(helper.find('.list-group-item.enterprises').length).toEqual(1, "The statistics-block should have a list item with enterprises class"); | |
83 | + }); | |
81 | 84 | |
82 | - // it("should not render user count information if has no configuration on block", () => { | |
83 | - // helper.component.counters.forEach((obj: any) => { delete obj.$$hashKey }); | |
84 | - // expect(helper.component.counters).toContain({ 'should_display': 1, 'value': 30, 'name': 'enterprises' }); | |
85 | - // }); | |
85 | + it("should render the product count information", () => { | |
86 | + expect(helper.find('.list-group-item.products').length).toEqual(1, "The statistics-block should have a list item with products class"); | |
87 | + }); | |
86 | 88 | |
87 | - // this.counters.push({ 'should_display': this.block.enterprise_counter, 'value': this.block.enterprises, 'name': 'enterprises' }) | |
88 | - // this.counters.push({ 'should_display': this.block.product_counter, 'value': this.block.products, 'name': 'products' }) | |
89 | - // this.counters.push({ 'should_display': this.block.community_counter, 'value': this.block.communities, 'name': 'communities' }) | |
90 | - // this.counters.push({ 'should_display': this.block.category_counter, 'value': this.block.categories, 'name': 'categories' }) | |
91 | - // this.counters.push({ 'should_display': this.block.tag_counter, 'value': this.block.tags, 'name': 'tags' }) | |
92 | - // this.counters.push({ 'should_display': this.block.comment_counter, 'value': this.block.comments, 'name': 'comments' }) | |
93 | - // this.counters.push({ 'should_display': this.block.hit_counter, 'value': this.block.hits, 'name': 'hits' }) | |
94 | - | |
95 | - /** | |
96 | - * There are helper functions to access the JQuery DOM like this. | |
97 | - */ | |
98 | - // it("render the profile image for each person", () => { | |
99 | - // expect(helper.all("list-group-item").length).toEqual(3); | |
100 | - // }); | |
89 | + it("should render the community count information", () => { | |
90 | + expect(helper.find('.list-group-item.communities').length).toEqual(1, "The statistics-block should have a list item with communities class"); | |
91 | + }); | |
92 | + | |
93 | + it("should render the category count information", () => { | |
94 | + expect(helper.find('.list-group-item.categories').length).toEqual(1, "The statistics-block should have a list item with categories class"); | |
95 | + }); | |
101 | 96 | |
102 | - /** | |
103 | - * The main debugElement element is also available | |
104 | - */ | |
105 | - // it("render the main noosfero people block", () => { | |
106 | - // expect(helper.debugElement.children().length).toEqual(1, "The people-block should have a div children"); | |
97 | + it("should render the tag count information", () => { | |
98 | + expect(helper.find('.list-group-item.tags').length).toEqual(1, "The statistics-block should have a list item with tags class"); | |
99 | + }); | |
100 | + | |
101 | + it("should render the comment count information", () => { | |
102 | + expect(helper.find('.list-group-item.comments').length).toEqual(1, "The statistics-block should have a list item with comments class"); | |
103 | + }); | |
104 | + | |
105 | + it("should render the hit count information", () => { | |
106 | + expect(helper.find('.list-group-item.hits').length).toEqual(1, "The statistics-block should have a list item with hits class"); | |
107 | + }); | |
108 | + | |
109 | + // it("should not render user count information if has no configuration on block", () => { | |
110 | + // helper.component.counters.forEach((obj: any) => { delete obj.$$hashKey; }); | |
111 | + // expect(helper.component.counters).toContain({ 'should_display': 0, 'value': 0, 'name': 'users' }); | |
112 | + // expect(helper.find('.list-group-item.users').length).toEqual(0, "The statistics-block should not have a list item with users class"); | |
107 | 113 | // }); |
108 | 114 | |
109 | - /** | |
110 | - * Just another example of a JQuery DOM helper function | |
111 | - */ | |
112 | - // it("render the noosfero people block div", () => { | |
113 | - // let div = helper.findChildren("noosfero-people-block", "div"); | |
114 | - // expect(div.className).toBe('people-block', "The class should be people-block"); | |
115 | - // }); | |
116 | 115 | }); |
117 | 116 | }); | ... | ... |