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.

110 lines
3.6 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. /**
  16. * Tests Ext.data.Store functionality
  17. * @author Ed Spencer
  18. */
  19. (function() {
  20. var suite = Ext.test.session.getSuite('Ext.layout.FormLayout'),
  21. assert = Y.Assert;
  22. function buildLayout(config) {
  23. var layout = new Ext.layout.FormLayout(config || {});
  24. //give a mock container
  25. layout.container = {
  26. itemCls: 'ctCls'
  27. };
  28. return layout;
  29. };
  30. suite.add(new Y.Test.Case({
  31. name: 'getTemplateArgs',
  32. setUp: function() {
  33. this.layout = buildLayout({
  34. labelStyle : 'color: red;',
  35. elementStyle: 'padding-left:0;'
  36. });
  37. //mock fields
  38. this.field1 = {
  39. id : 'myField',
  40. itemCls : 'myCls',
  41. clearCls : 'myClearCls',
  42. fieldLabel: 'A Label',
  43. labelStyle: 'border-top: 10px;'
  44. };
  45. this.field2 = {
  46. id : 'myField2',
  47. fieldLabel : 'My Label',
  48. labelSeparator: '@'
  49. };
  50. this.field3 = Ext.apply({}, {
  51. fieldLabel: 'Third label',
  52. hideLabel : true
  53. }, this.field2);
  54. this.args1 = this.layout.getTemplateArgs(this.field1);
  55. this.args2 = this.layout.getTemplateArgs(this.field2);
  56. this.args3 = this.layout.getTemplateArgs(this.field3);
  57. },
  58. testId: function() {
  59. assert.areEqual('myField', this.args1.id);
  60. assert.areEqual('myField2', this.args2.id);
  61. },
  62. testLabel: function() {
  63. assert.areEqual('A Label', this.args1.label);
  64. assert.areEqual('My Label', this.args2.label);
  65. assert.areEqual('Third label', this.args3.label);
  66. },
  67. //adds field's label style to layout's general label style
  68. testLabelStyle: function() {
  69. assert.areEqual('color: red;border-top: 10px;', this.args1.labelStyle);
  70. },
  71. testElementStyle: function() {
  72. assert.areEqual('padding-left:0;', this.args1.elementStyle);
  73. },
  74. testLabelSeparator: function() {
  75. assert.areEqual(':', this.args1.labelSeparator);
  76. assert.areEqual('@', this.args2.labelSeparator);
  77. assert.areEqual('', this.args3.labelSeparator);
  78. },
  79. testItemCls: function() {
  80. assert.areEqual('myCls', this.args1.itemCls);
  81. assert.areEqual('ctCls', this.args2.itemCls);
  82. assert.areEqual('ctCls x-hide-label', this.args3.itemCls);
  83. },
  84. testClearCls: function() {
  85. assert.areEqual('myClearCls', this.args1.clearCls);
  86. assert.areEqual('x-form-clear-left', this.args2.clearCls);
  87. }
  88. }));
  89. })();