DYEBench should use TodoMVC to test FlightJS for consistency
[WebKit-https.git] / PerformanceTests / DoYouEvenBench / resources / todomvc / dependency-examples / flight / test / spec / ui / stats_spec.js
1 describeComponent('app/js/ui/stats', function () {
2     'use strict';
3
4     beforeEach(function () {
5         setupComponent(readFixtures('footer.html'));
6     });
7
8     it('renders when stats change', function () {
9         var data = {
10             all: 3,
11             remaining: 2,
12             completed: 1,
13             filter: ''
14         };
15         expect(this.component.$node).toBeEmpty();
16         $(document).trigger('dataStatsCounted', data);
17         expect(this.component.$node).not.toBeEmpty();
18         expect(this.component.$node).toBeVisible();
19     });
20
21     it('is hidden when data is empty', function () {
22         var data = {
23             all: 0,
24             remaining: 0,
25             completed: 0,
26             filter: ''
27         };
28         $(document).trigger('dataStatsCounted', data);
29         expect(this.component.$node).toBeHidden();
30     });
31
32     it('hides clear-completed with no completed items', function () {
33         var data = {
34             all: 2,
35             remaining: 2,
36             completed: 0,
37             filter: ''
38         };
39         this.component.render(null, data);
40         expect(this.component.select('clearCompletedSelector').length).toBe(0);
41     });
42
43     it('shows clear-completed with completed items', function () {
44         var data = {
45             all: 2,
46             remaining: 1,
47             completed: 1,
48             filter: ''
49         };
50         this.component.render(null, data);
51         expect(this.component.select('clearCompletedSelector').length).toBe(1);
52     });
53
54     it('triggers uiClearRequested on click', function () {
55         var data = {
56             all: 2,
57             remaining: 1,
58             completed: 1,
59             filter: ''
60         };
61         spyOnEvent(document, 'uiClearRequested');
62         this.component.render(null, data);
63         this.component.trigger(this.component.attr.clearCompletedSelector, 'click');
64         expect('uiClearRequested').toHaveBeenTriggeredOn(this.component);
65     });
66 });