Unreviewed, rolling out r216677.
[WebKit-https.git] / PerformanceTests / Speedometer / resources / todomvc / dependency-examples / flight / test / spec / ui / new_item_spec.js
1 describeComponent('app/js/ui/new_item', function () {
2     'use strict';
3
4     var ENTER_KEY = 13;
5
6     beforeEach(function () {
7         setupComponent(readFixtures('new_todo.html'));
8     });
9
10     it('triggers uiAddRequested on enter', function () {
11         var event = $.Event('keydown');
12         event.which = ENTER_KEY;
13
14         spyOnEvent(document, 'uiAddRequested');
15         this.component.$node.val('shave moar yaks');
16
17         this.component.trigger(event);
18
19         expect('uiAddRequested').toHaveBeenTriggeredOnAndWith(document, {
20             title: 'shave moar yaks'
21         });
22     });
23
24     it('trims values', function () {
25         var event = $.Event('keydown');
26         event.which = ENTER_KEY;
27
28         spyOnEvent(document, 'uiAddRequested');
29         this.component.$node.val('  trim inputs ');
30
31         this.component.trigger(event);
32
33         expect('uiAddRequested').toHaveBeenTriggeredOnAndWith(document, {
34             title: 'trim inputs'
35         });
36     });
37
38     it('ignore empty values', function () {
39         var event = $.Event('keydown');
40         event.which = ENTER_KEY;
41
42         spyOnEvent(document, 'uiAddRequested');
43
44         this.component.trigger(event);
45
46         expect('uiAddRequested').not.toHaveBeenTriggeredOn(document);
47     });
48 });
49