3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
7 Ext.test.session.addTest('Ext.data.Field', {
8 name: 'Test data field creation',
11 this.t = Ext.data.Types;
12 this.st = Ext.data.SortTypes;
20 test_alias: function(){
23 f = new Ext.data.Field({type: null});
24 Y.Assert.areEqual(this.t.AUTO, f.type, 'Test empty alias');
25 f = new Ext.data.Field({type: 'auto'});
26 Y.Assert.areEqual(this.t.AUTO, f.type, 'Test auto alias');
28 f = new Ext.data.Field({type: 'int'});
29 Y.Assert.areEqual(this.t.INT, f.type, 'Test int alias');
30 f = new Ext.data.Field({type: 'integer'});
31 Y.Assert.areEqual(this.t.INT, f.type, 'Test integer alias');
33 f = new Ext.data.Field({type: 'float'});
34 Y.Assert.areEqual(this.t.FLOAT, f.type, 'Test float alias');
35 f = new Ext.data.Field({type: 'number'});
36 Y.Assert.areEqual(this.t.FLOAT, f.type, 'Test number alias');
38 f = new Ext.data.Field({type: 'bool'});
39 Y.Assert.areEqual(this.t.BOOL, f.type, 'Test bool alias');
40 f = new Ext.data.Field({type: 'boolean'});
41 Y.Assert.areEqual(this.t.BOOL, f.type, 'Test boolean alias');
43 f = new Ext.data.Field({type: 'string'});
44 Y.Assert.areEqual(this.t.STRING, f.type, 'Test string alias');
46 f = new Ext.data.Field({type: 'date'});
47 Y.Assert.areEqual(this.t.DATE, f.type, 'Test date alias');
50 test_type: function(){
53 f = new Ext.data.Field({type: this.t.INT});
54 Y.Assert.areEqual(this.t.INT, f.type, 'Test int type');
56 f = new Ext.data.Field({type: this.t.AUTO});
57 Y.Assert.areEqual(this.t.AUTO, f.type, 'Test auto type');
59 f = new Ext.data.Field({type: this.t.STRING});
60 Y.Assert.areEqual(this.t.STRING, f.type, 'Test string type');
63 test_sortType: function(){
72 f = new Ext.data.Field({type: 'auto'});
73 Y.Assert.areEqual(this.st.none, f.sortType, 'Test sort type defaults for auto');
75 f = new Ext.data.Field({type: 'int'});
76 Y.Assert.areEqual(this.st.none, f.sortType, 'Test sort type defaults for int');
78 f = new Ext.data.Field({type: 'float'});
79 Y.Assert.areEqual(this.st.none, f.sortType, 'Test sort type defaults for float');
81 f = new Ext.data.Field({type: 'bool'});
82 Y.Assert.areEqual(this.st.none, f.sortType, 'Test sort type defaults for bool');
84 f = new Ext.data.Field({type: 'string'});
85 Y.Assert.areEqual(this.st.asUCString, f.sortType, 'Test sort type defaults for string');
87 f = new Ext.data.Field({type: 'date'});
88 Y.Assert.areEqual(this.st.asDate, f.sortType, 'Test sort type defaults for date');
90 f = new Ext.data.Field({
94 Y.Assert.areEqual(this.st.asDate, f.sortType, 'Test with custom string sortType');
96 f = new Ext.data.Field({
100 Y.Assert.areEqual(s1, f.sortType, 'Test with custom function sortType');
102 f = new Ext.data.Field({
106 Y.Assert.areEqual(s2, f.sortType, 'Test with another custom function sortType');
109 test_convert: function(){
118 f = new Ext.data.Field({type: 'auto'});
119 Y.Assert.areEqual(this.t.AUTO.convert, f.convert, 'Test convert for auto');
121 f = new Ext.data.Field({type: 'int'});
122 Y.Assert.areEqual(this.t.INT.convert, f.convert, 'Test convert for int');
124 f = new Ext.data.Field({type: 'float'});
125 Y.Assert.areEqual(this.t.FLOAT.convert, f.convert, 'Test convert for float');
127 f = new Ext.data.Field({type: 'bool'});
128 Y.Assert.areEqual(this.t.BOOL.convert, f.convert, 'Test convert for bool');
130 f = new Ext.data.Field({type: 'string'});
131 Y.Assert.areEqual(this.t.STRING.convert, f.convert, 'Test convert for string');
133 f = new Ext.data.Field({type: 'date'});
134 Y.Assert.areEqual(this.t.DATE.convert, f.convert, 'Test convert for date');
136 f = new Ext.data.Field({
140 Y.Assert.areEqual(c1, f.convert, 'Test with custom function convert');
142 f = new Ext.data.Field({
146 Y.Assert.areEqual(c2, f.convert, 'Test with another custom function convert');