source:
trunk/workshop-routing-foss4g/web/ext/test/unit/widgets/FormPanel.js
@
81
Revision 76, 2.9 KB checked in by djay, 13 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /*! |
2 | * Ext JS Library 3.4.0 |
3 | * Copyright(c) 2006-2011 Sencha Inc. |
4 | * licensing@sencha.com |
5 | * http://www.sencha.com/license |
6 | */ |
7 | /** |
8 | * Tests Ext.data.Store functionality |
9 | * @author Ed Spencer |
10 | */ |
11 | (function() { |
12 | var suite = Ext.test.session.getSuite('Ext.form.FormPanel'), |
13 | assert = Y.Assert; |
14 | |
15 | function buildForm(config) { |
16 | return new Ext.form.FormPanel(config); |
17 | }; |
18 | |
19 | suite.add(new Y.Test.Case({ |
20 | name: 'initialization', |
21 | |
22 | testCreatesForm: function() { |
23 | var form = buildForm(); |
24 | |
25 | assert.isTrue(form.form instanceof Ext.form.BasicForm); |
26 | }, |
27 | |
28 | testInitsItems: function() { |
29 | var FormPanel = Ext.form.FormPanel, |
30 | proto = FormPanel.prototype, |
31 | oldInit = proto.initItems, |
32 | wasCalled = false; |
33 | |
34 | proto.initItems = function() { |
35 | wasCalled = true; |
36 | }; |
37 | |
38 | var form = buildForm(); |
39 | assert.isTrue(wasCalled); |
40 | |
41 | proto.initItems = oldInit; |
42 | }, |
43 | |
44 | testStartsMonitoring: function() { |
45 | var FormPanel = Ext.form.FormPanel, |
46 | proto = FormPanel.prototype, |
47 | oldFunc = proto.startMonitoring, |
48 | wasCalled = false; |
49 | |
50 | proto.startMonitoring = function() { |
51 | wasCalled = true; |
52 | }; |
53 | |
54 | var form = buildForm({ |
55 | monitorValid: true, |
56 | renderTo : Ext.getBody() |
57 | }); |
58 | |
59 | form.render(); |
60 | assert.isTrue(wasCalled); |
61 | |
62 | proto.startMonitoring = oldFunc; |
63 | form.destroy(); |
64 | } |
65 | })); |
66 | |
67 | suite.add(new Y.Test.Case({ |
68 | name: 'destruction', |
69 | |
70 | testStopMonitoring: function() { |
71 | var FormPanel = Ext.form.FormPanel, |
72 | proto = FormPanel.prototype, |
73 | oldFunc = proto.stopMonitoring, |
74 | wasCalled = false; |
75 | |
76 | proto.stopMonitoring = function() { |
77 | wasCalled = true; |
78 | }; |
79 | |
80 | var form = buildForm({ |
81 | monitorValid: true, |
82 | renderTo : Ext.getBody() |
83 | }); |
84 | |
85 | form.render(); |
86 | form.destroy(); |
87 | assert.isTrue(wasCalled); |
88 | |
89 | proto.stopMonitoring = oldFunc; |
90 | } |
91 | })); |
92 | |
93 | suite.add(new Y.Test.Case({ |
94 | name: 'initFields', |
95 | |
96 | testIsField: function() { |
97 | var mockField = { |
98 | setValue : Ext.emptyFn, |
99 | getValue : Ext.emptyFn, |
100 | markInvalid : Ext.emptyFn, |
101 | clearInvalid: Ext.emptyFn |
102 | }; |
103 | |
104 | var form = buildForm(); |
105 | |
106 | assert.isTrue(form.isField(mockField)); |
107 | } |
108 | })); |
109 | })(); |
Note: See TracBrowser
for help on using the repository browser.