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.

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