3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
8 * Tests Ext.data.Store functionality
12 var suite = Ext.test.session.getSuite('Ext.grid.GridPanel'),
15 //builds and returns a grid with some default config
16 var buildGrid = function(config) {
17 config = config || {};
20 store: new Ext.data.ArrayStore({
27 {name: 'price', type: 'float'},
28 {name: 'change', type: 'float'},
29 {name: 'pctChange', type: 'float'},
30 {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
34 ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
35 ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
36 ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
37 ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
38 ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
42 colModel: new Ext.grid.ColumnModel({
44 {header: 'Name', dataIndex: 'company'}
48 selModel: new Ext.grid.RowSelectionModel()
51 return new Ext.grid.GridPanel(config);
54 suite.add(new Y.Test.Case({
55 name: 'constructor and initComponent',
57 testDisallowsAutoScroll: function() {
58 var grid = buildGrid({autoScroll: true});
60 assert.isFalse(grid.autoScroll);
63 testDisallowsAutoWidth: function() {
64 var grid = buildGrid({autoWidth: true});
66 assert.isFalse(grid.autoWidth);
69 testDsTranslatedToStore: function() {
70 var store = new Ext.data.ArrayStore({fields: ['name']}),
71 grid = buildGrid({ds: store, store: null});
73 assert.areEqual(store, grid.store);
74 assert.isUndefined(grid.ds);
77 testCmTranslatedToColModel: function() {
78 var colModel = new Ext.grid.ColumnModel({columns: [{header: 'my header'}]}),
79 grid = buildGrid({cm: colModel, colModel: null});
81 assert.areEqual(colModel, grid.colModel);
82 assert.isUndefined(grid.cm);
85 testColumnsTurnedIntoColModel: function() {
87 {header: 'first', dataIndex: 'company'}, {header: 'second', dataIndex: 'price'}
89 var grid = buildGrid({columns: columns, colModel: null});
91 var colModel = grid.colModel;
92 assert.areEqual(2, colModel.getColumnCount());
96 suite.add(new Y.Test.Case({
100 suite.add(new Y.Test.Case({