]> git.proxmox.com Git - extjs.git/blob - extjs/classic/classic/test/specs/menu/DatePicker.js
add extjs 6.0.1 sources
[extjs.git] / extjs / classic / classic / test / specs / menu / DatePicker.js
1 describe("Ext.menu.DatePicker", function() {
2 var expectFocused = jasmine.expectFocused,
3 pressKey = jasmine.asyncPressKey,
4 menu;
5
6 function makeMenu(cfg) {
7 cfg = Ext.apply({
8 floating: true,
9 }, cfg);
10
11 menu = new Ext.menu.DatePicker(cfg);
12
13 return menu;
14 }
15
16 afterEach(function() {
17 if (menu) {
18 menu.destroy();
19 }
20
21 menu = null;
22 });
23
24 describe("pickerCfg", function() {
25 beforeEach(function() {
26 makeMenu({
27 pickerCfg: {
28 foo: 'bar'
29 },
30
31 blerg: 'throbbe'
32 });
33 });
34
35 it("should apply pickerCfg", function() {
36 expect(menu.picker.foo).toBe('bar');
37 });
38
39 it("should not apply other configs", function() {
40 expect(menu.picker.blerg).not.toBeDefined();
41 });
42 });
43
44 describe("no pickerCfg", function() {
45 it("should apply config", function() {
46 makeMenu({
47 frobbe: 'gurgle'
48 });
49
50 expect(menu.picker.frobbe).toBe('gurgle');
51 });
52 });
53
54 describe("keyboard interaction", function() {
55 var button, dateItem;
56
57 beforeEach(function() {
58 button = new Ext.button.Button({
59 renderTo: Ext.getBody(),
60 text: 'foo',
61 menu: [{
62 text: 'no submenu'
63 }, {
64 text: 'date',
65 menu: {
66 xtype: 'datemenu'
67 }
68 }]
69 });
70
71 button.showMenu();
72
73 dateItem = button.menu.down('[text=date]');
74
75 dateItem.focus();
76 dateItem.expandMenu(null, 0);
77
78 menu = dateItem.menu;
79 });
80
81 afterEach(function() {
82 if (button) {
83 button.destroy();
84 }
85
86 button = null;
87 });
88
89 it("should focus the picker eventEl on open", function() {
90 expectFocused(menu.picker.eventEl, false);
91 });
92
93 it("should close the date menu on Esc key", function() {
94 pressKey(menu.picker.eventEl, 'esc');
95
96 waitsFor(function() {
97 return !menu.isVisible();
98 }, 'Date menu to hide', 1000);
99
100 runs(function() {
101 expect(menu.isVisible()).toBeFalsy();
102 });
103 });
104
105 it("should focus the owner menu item on Esc key", function() {
106 pressKey(menu.picker.eventEl, 'esc');
107
108 expectFocused(dateItem);
109 });
110 });
111 });