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