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.

116 lines
3.8 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.grid.GridPanel'),
  21. assert = Y.Assert;
  22. //builds and returns a grid with some default config
  23. var buildGrid = function(config) {
  24. config = config || {};
  25. Ext.applyIf(config, {
  26. store: new Ext.data.ArrayStore({
  27. autoDestroy: true,
  28. storeId: 'myStore',
  29. idIndex: 0,
  30. fields : [
  31. 'company',
  32. {name: 'price', type: 'float'},
  33. {name: 'change', type: 'float'},
  34. {name: 'pctChange', type: 'float'},
  35. {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  36. ],
  37. data: [
  38. ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  39. ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
  40. ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
  41. ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
  42. ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
  43. ]
  44. }),
  45. colModel: new Ext.grid.ColumnModel({
  46. columns: [
  47. {header: 'Name', dataIndex: 'company'}
  48. ]
  49. }),
  50. selModel: new Ext.grid.RowSelectionModel()
  51. });
  52. return new Ext.grid.GridPanel(config);
  53. };
  54. suite.add(new Y.Test.Case({
  55. name: 'constructor and initComponent',
  56. testDisallowsAutoScroll: function() {
  57. var grid = buildGrid({autoScroll: true});
  58. assert.isFalse(grid.autoScroll);
  59. },
  60. testDisallowsAutoWidth: function() {
  61. var grid = buildGrid({autoWidth: true});
  62. assert.isFalse(grid.autoWidth);
  63. },
  64. testDsTranslatedToStore: function() {
  65. var store = new Ext.data.ArrayStore({fields: ['name']}),
  66. grid = buildGrid({ds: store, store: null});
  67. assert.areEqual(store, grid.store);
  68. assert.isUndefined(grid.ds);
  69. },
  70. testCmTranslatedToColModel: function() {
  71. var colModel = new Ext.grid.ColumnModel({columns: [{header: 'my header'}]}),
  72. grid = buildGrid({cm: colModel, colModel: null});
  73. assert.areEqual(colModel, grid.colModel);
  74. assert.isUndefined(grid.cm);
  75. },
  76. testColumnsTurnedIntoColModel: function() {
  77. var columns = [
  78. {header: 'first', dataIndex: 'company'}, {header: 'second', dataIndex: 'price'}
  79. ];
  80. var grid = buildGrid({columns: columns, colModel: null});
  81. var colModel = grid.colModel;
  82. assert.areEqual(2, colModel.getColumnCount());
  83. }
  84. }));
  85. suite.add(new Y.Test.Case({
  86. name: 'reconfigure'
  87. }));
  88. suite.add(new Y.Test.Case({
  89. name: 'walk cells'
  90. }));
  91. })();