Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / core / test / unit / spec / version / Version.js
1 describe("Ext.Version", function() {
2                 var version = new Ext.Version("1.2.3beta");
3
4                 describe("toString", function() {
5                         it("should cast to string", function() {
6                                 expect(version+"").toBe("1.2.3beta");
7                         });
8                 });
9
10                 describe("getMajor", function() {
11                         it("should return 1", function() {
12                                 expect(version.getMajor()).toBe(1);
13                         });
14                 });
15
16                 describe("getMinor", function() {
17                         it("should return 2", function() {
18                                 expect(version.getMinor()).toBe(2);
19                         });
20                 });
21
22                 describe("getPatch", function() {
23                         it("should return 3", function() {
24                                 expect(version.getPatch()).toBe(3);
25                         });
26                 });
27
28                 describe("getBuild", function() {
29                         it("should return 0", function() {
30                                 expect(version.getBuild()).toBe(0);
31                         });
32                 });
33
34                 describe("getRelease", function() {
35                         it("should return beta", function() {
36                                 expect(version.getRelease()).toBe("beta");
37                         });
38                 });
39
40                 describe("getShortVersion", function() {
41                         it("should return 123", function() {
42                                 expect(version.getShortVersion()).toBe("123");
43                         });
44                 });
45
46                 describe("toArray", function() {
47                         it("should return [1, 2, 3, 0, 'beta']", function() {
48                                 expect(version.toArray()).toEqual([1, 2, 3, 0, 'beta']);
49                         });
50                 });
51
52                 describe("isGreaterThan", function() {
53                         it("should be greater than 1.2.3alpha", function() {
54                                 expect(version.isGreaterThan("1.2.3alpha")).toBeTruthy();
55                         });
56                         it("should not be greater than 1.2.3RC", function() {
57                                 expect(version.isGreaterThan("1.2.3RC")).toBeFalsy();
58                         });
59                 });
60
61                 describe("isLessThan", function() {
62                         it("should not be smaller than 1.2.3alpha", function() {
63                                 expect(version.isLessThan("1.2.3alpha")).toBeFalsy();
64                         });
65                         it("should be smaller than 1.2.3RC", function() {
66                                 expect(version.isLessThan("1.2.3RC")).toBeTruthy();
67                         });
68                 });
69
70                 describe("equals", function() {
71                         it("should equals 1.2.3beta", function() {
72                                 expect(version.equals("1.2.3beta")).toBeTruthy();
73                         });
74                 });
75
76                 describe("match", function() {
77                         it("should match integer 1", function() {
78                                 expect(version.match(1)).toBeTruthy();
79                         });
80                         it("should match float 1.2", function() {
81                                 expect(version.match(1.2)).toBeTruthy();
82                         });
83                         it("should match string 1.2.3", function() {
84                                 expect(version.match("1.2.3")).toBeTruthy();
85                         });
86                         it("should not match string 1.2.3alpha", function() {
87                                 expect(version.match("1.2.3alpha")).toBeFalsy();
88                         });
89                 });
90         });
91
92         describe("Ext.Version Statics", function() {
93
94                 describe("getComponentValue", function() {
95                         it("should return 0", function() {
96                                 expect(Ext.Version.getComponentValue(undefined)).toBe(0);
97                         });
98
99                         it("should return -2", function() {
100                                 expect(Ext.Version.getComponentValue(-2)).toBe(-2);
101                         });
102
103                         it("should return 2", function() {
104                                 expect(Ext.Version.getComponentValue("2")).toBe(2);
105                         });
106
107                         it("should return -5", function() {
108                                 expect(Ext.Version.getComponentValue("alpha")).toBe(-5);
109                         });
110
111                         it("should return unknown", function() {
112                                 expect(Ext.Version.getComponentValue("unknown")).toBe("unknown");
113                         });
114                 });
115
116                 describe("compare", function() {
117                         it("should return 1", function() {
118                                 expect(Ext.Version.compare("1.2.3beta", "1.2.2")).toBe(1);
119                         });
120
121                         it("should return 1", function() {
122                                 expect(Ext.Version.compare("1.2.3beta", 1)).toBe(1);
123                         });
124
125                         it("should return -1", function() {
126                                 expect(Ext.Version.compare("1.2.3beta", 2)).toBe(-1);
127                         });
128
129                         it("should return -1", function() {
130                                 expect(Ext.Version.compare("1.2.3beta", "1.2.4")).toBe(-1);
131                         });
132
133                         it("should return 1", function() {
134                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3dev")).toBe(1);
135                         });
136
137                         it("should return 1", function() {
138                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3alpha")).toBe(1);
139                         });
140
141                         it("should return 1", function() {
142                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3a")).toBe(1);
143                         });
144
145                         it("should return 0", function() {
146                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3b")).toBe(0);
147                         });
148
149                         it("should return 0", function() {
150                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3beta")).toBe(0);
151                         });
152
153                         it("should return 1", function() {
154                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3alpha")).toBe(1);
155                         });
156
157                         it("should return -1", function() {
158                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3RC")).toBe(-1);
159                         });
160
161                         it("should return -1", function() {
162                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3rc")).toBe(-1);
163                         });
164
165                         it("should return -1", function() {
166                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3#")).toBe(-1);
167                         });
168
169                         it("should return -1", function() {
170                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3pl")).toBe(-1);
171                         });
172
173                         it("should return -1", function() {
174                                 expect(Ext.Version.compare("1.2.3beta", "1.2.3p")).toBe(-1);
175                         });
176                 });
177         });
178
179
180         describe("Versioning", function() {
181                 describe("Ext.setVersion", function() {
182                         it("should return an instance of Ext.Version", function() {
183                                 Ext.setVersion("test", "1.0.1");
184
185                                 expect(Ext.getVersion("test") instanceof Ext.Version).toBe(true);
186                         });
187                 });
188
189                 describe("deprecated Ext.version", function() {
190                         it("should be undefined", function() {
191                                 expect(Ext.version).toBe(undefined);
192                         });
193                 });
194 });