]> git.proxmox.com Git - extjs.git/blob - extjs/packages/core/test/specs/data/field/String.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / test / specs / data / field / String.js
1 describe("Ext.data.field.String", function() {
2
3 var field;
4
5 function make(cfg) {
6 field = new Ext.data.field.String(cfg);
7 }
8
9 function c(v) {
10 return field.convert(v);
11 }
12
13 afterEach(function() {
14 field = null;
15 });
16
17 describe("defaults", function() {
18 it("should configure the type", function() {
19 make();
20 expect(field.getType()).toBe('string');
21 });
22 });
23
24 describe("convert", function() {
25 describe("with allowNull: true", function() {
26 beforeEach(function() {
27 make({
28 allowNull: true
29 });
30 });
31
32 it("should return null with undefined", function() {
33 expect(c(undefined)).toBeNull();
34 });
35
36 it("should return null with null", function() {
37 expect(c(null)).toBeNull();
38 });
39 });
40
41 describe("with allowNull: false", function() {
42 beforeEach(function() {
43 make({
44 allowNull: false
45 });
46 });
47
48 it("should return '' with undefined", function() {
49 expect(c(undefined)).toBe('');
50 });
51
52 it("should return null with null", function() {
53 expect(c(null)).toBe('');
54 });
55 });
56
57 it("should return a stringified bool", function() {
58 make();
59 expect(c(true)).toBe('true');
60 });
61
62 it("should return a stringified number", function() {
63 make();
64 expect(c(2)).toBe('2');
65 });
66
67 it("should return a string", function() {
68 make();
69 expect(c('foo')).toBe('foo');
70 });
71 });
72 });