]> git.proxmox.com Git - extjs.git/blob - extjs/classic/classic/test/specs/app/domain/Component.js
add extjs 6.0.1 sources
[extjs.git] / extjs / classic / classic / test / specs / app / domain / Component.js
1 describe("Ext.app.domain.Component", function() {
2 var panel, ctrl;
3
4 beforeEach(function() {
5 panel = new Ext.panel.Panel({
6 renderTo: Ext.getBody(),
7
8 width: 100,
9 height: 100
10 });
11
12 ctrl = new Ext.app.Controller({
13 id: 'foo'
14 });
15 });
16
17 afterEach(function() {
18 Ext.destroy(panel);
19 });
20
21 it("should ignore case on event names", function() {
22 var handler = jasmine.createSpy('foo handler');
23
24 ctrl.control({
25 panel: {
26 foo: handler
27 }
28 });
29
30 panel.fireEvent('FOO');
31
32 expect(handler).toHaveBeenCalled();
33 });
34
35 it("controls Component events with control() method", function() {
36 var handler = jasmine.createSpy('foo handler');
37
38 ctrl.control({
39 panel: {
40 foo: handler
41 }
42 });
43
44 panel.fireEvent('foo');
45
46 expect(handler).toHaveBeenCalled();
47 });
48
49 it("listens to Component events with listen() method", function() {
50 var handler = jasmine.createSpy('bar handler');
51
52 ctrl.listen({
53 component: {
54 panel: {
55 bar: handler
56 }
57 }
58 });
59
60 panel.fireEvent('bar');
61
62 expect(handler).toHaveBeenCalled();
63 });
64
65 describe('looking up a menu as the direct child of a menu item', function () {
66 var handler, menu;
67
68 beforeEach(function () {
69 handler = jasmine.createSpy('foo handler');
70
71 menu = new Ext.menu.Menu({
72 width: 100,
73 items: [{
74 itemId: 'foobar',
75 menu: new Ext.menu.Menu({
76 id: 'childMenu',
77 items: [{
78 text: 'A'
79 }]
80 })
81 }],
82 renderTo: Ext.getBody()
83 });
84 });
85
86 afterEach(function () {
87 Ext.destroy(menu);
88 handler = menu = null;
89 });
90
91 it('should find the owner of the menu as a descendant of the menu item', function () {
92 ctrl.control({
93 '#foobar menu': {
94 foo: handler
95 }
96 });
97
98 Ext.getCmp('childMenu').fireEvent('foo');
99
100 expect(handler).toHaveBeenCalled();
101 });
102
103 it('should find the owner of the menu as a direct child of the menu item', function () {
104 ctrl.control({
105 '#foobar > menu': {
106 foo: handler
107 }
108 });
109
110 Ext.getCmp('childMenu').fireEvent('foo');
111
112 expect(handler).toHaveBeenCalled();
113 });
114 });
115 });