]> git.proxmox.com Git - extjs.git/blob - extjs/classic/classic/test/specs/grid/column/Date.js
add extjs 6.0.1 sources
[extjs.git] / extjs / classic / classic / test / specs / grid / column / Date.js
1 describe("Ext.grid.column.Date", function() {
2
3 var grid, store, colRef;
4
5 function getCell(rowIdx, colIdx) {
6 return grid.getView().getCellInclusive({
7 row: rowIdx,
8 column: colIdx
9 });
10 }
11
12 function getCellText(rowIdx, colIdx) {
13 var cell = getCell(rowIdx, colIdx);
14 return Ext.fly(cell).down(grid.getView().innerSelector).dom.innerHTML;
15 }
16
17 function makeGrid(value) {
18 store = new Ext.data.Store({
19 model: spec.TestModel,
20 data: [{
21 field: value
22 }]
23 });
24
25 grid = new Ext.grid.Panel({
26 store: store,
27 columns: [{
28 xtype: 'datecolumn',
29 format: 'Y-m-d',
30 text: 'Col',
31 dataIndex: 'field',
32 flex: 1
33 }],
34 width: 400,
35 height: 100,
36 border: false,
37 renderTo: Ext.getBody()
38 });
39 colRef = grid.getColumnManager().getColumns();
40 }
41
42 beforeEach(function() {
43 Ext.define('spec.TestModel', {
44 extend: 'Ext.data.Model',
45 fields: [{
46 name: 'field',
47 defaultValue: undefined
48 }]
49 });
50 });
51
52 afterEach(function(){
53 Ext.destroy(grid, store);
54 colRef = store = grid = null;
55 Ext.undefine('spec.TestModel');
56 Ext.data.Model.schema.clear();
57 });
58
59 describe("renderer", function() {
60 it("should render render non-date values", function() {
61 makeGrid(null);
62 var text = getCellText(0, 0);
63 if (text === ' ') {
64 text = ' '
65 }
66 expect(text).toBe(' ');
67 });
68
69 it("should render the date according to the format", function() {
70 makeGrid(new Date(2010, 2, 3));
71 expect(getCellText(0, 0)).toBe('2010-03-03');
72 });
73 });
74
75 });