Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.9 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 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. function buildForm(config) {
  15. return new Ext.form.FormPanel(config);
  16. };
  17. suite.add(new Y.Test.Case({
  18. name: 'initialization',
  19. testCreatesForm: function() {
  20. var form = buildForm();
  21. assert.isTrue(form.form instanceof Ext.form.BasicForm);
  22. },
  23. testInitsItems: function() {
  24. var FormPanel = Ext.form.FormPanel,
  25. proto = FormPanel.prototype,
  26. oldInit = proto.initItems,
  27. wasCalled = false;
  28. proto.initItems = function() {
  29. wasCalled = true;
  30. };
  31. var form = buildForm();
  32. assert.isTrue(wasCalled);
  33. proto.initItems = oldInit;
  34. },
  35. testStartsMonitoring: function() {
  36. var FormPanel = Ext.form.FormPanel,
  37. proto = FormPanel.prototype,
  38. oldFunc = proto.startMonitoring,
  39. wasCalled = false;
  40. proto.startMonitoring = function() {
  41. wasCalled = true;
  42. };
  43. var form = buildForm({
  44. monitorValid: true,
  45. renderTo : Ext.getBody()
  46. });
  47. form.render();
  48. assert.isTrue(wasCalled);
  49. proto.startMonitoring = oldFunc;
  50. form.destroy();
  51. }
  52. }));
  53. suite.add(new Y.Test.Case({
  54. name: 'destruction',
  55. testStopMonitoring: function() {
  56. var FormPanel = Ext.form.FormPanel,
  57. proto = FormPanel.prototype,
  58. oldFunc = proto.stopMonitoring,
  59. wasCalled = false;
  60. proto.stopMonitoring = function() {
  61. wasCalled = true;
  62. };
  63. var form = buildForm({
  64. monitorValid: true,
  65. renderTo : Ext.getBody()
  66. });
  67. form.render();
  68. form.destroy();
  69. assert.isTrue(wasCalled);
  70. proto.stopMonitoring = oldFunc;
  71. }
  72. }));
  73. suite.add(new Y.Test.Case({
  74. name: 'initFields',
  75. testIsField: function() {
  76. var mockField = {
  77. setValue : Ext.emptyFn,
  78. getValue : Ext.emptyFn,
  79. markInvalid : Ext.emptyFn,
  80. clearInvalid: Ext.emptyFn
  81. };
  82. var form = buildForm();
  83. assert.isTrue(form.isField(mockField));
  84. }
  85. }));
  86. })();