1 describe("Ext.Version", function() {
2 var version = new Ext.Version("1.2.3beta");
4 describe("toString", function() {
5 it("should cast to string", function() {
6 expect(version+"").toBe("1.2.3beta");
10 describe("getMajor", function() {
11 it("should return 1", function() {
12 expect(version.getMajor()).toBe(1);
16 describe("getMinor", function() {
17 it("should return 2", function() {
18 expect(version.getMinor()).toBe(2);
22 describe("getPatch", function() {
23 it("should return 3", function() {
24 expect(version.getPatch()).toBe(3);
28 describe("getBuild", function() {
29 it("should return 0", function() {
30 expect(version.getBuild()).toBe(0);
34 describe("getRelease", function() {
35 it("should return beta", function() {
36 expect(version.getRelease()).toBe("beta");
40 describe("getShortVersion", function() {
41 it("should return 123", function() {
42 expect(version.getShortVersion()).toBe("123");
46 describe("toArray", function() {
47 it("should return [1, 2, 3, 0, 'beta']", function() {
48 expect(version.toArray()).toEqual([1, 2, 3, 0, 'beta']);
52 describe("isGreaterThan", function() {
53 it("should be greater than 1.2.3alpha", function() {
54 expect(version.isGreaterThan("1.2.3alpha")).toBeTruthy();
56 it("should not be greater than 1.2.3RC", function() {
57 expect(version.isGreaterThan("1.2.3RC")).toBeFalsy();
61 describe("isLessThan", function() {
62 it("should not be smaller than 1.2.3alpha", function() {
63 expect(version.isLessThan("1.2.3alpha")).toBeFalsy();
65 it("should be smaller than 1.2.3RC", function() {
66 expect(version.isLessThan("1.2.3RC")).toBeTruthy();
70 describe("equals", function() {
71 it("should equals 1.2.3beta", function() {
72 expect(version.equals("1.2.3beta")).toBeTruthy();
76 describe("match", function() {
77 it("should match integer 1", function() {
78 expect(version.match(1)).toBeTruthy();
80 it("should match float 1.2", function() {
81 expect(version.match(1.2)).toBeTruthy();
83 it("should match string 1.2.3", function() {
84 expect(version.match("1.2.3")).toBeTruthy();
86 it("should not match string 1.2.3alpha", function() {
87 expect(version.match("1.2.3alpha")).toBeFalsy();
92 describe("Ext.Version Statics", function() {
94 describe("getComponentValue", function() {
95 it("should return 0", function() {
96 expect(Ext.Version.getComponentValue(undefined)).toBe(0);
99 it("should return -2", function() {
100 expect(Ext.Version.getComponentValue(-2)).toBe(-2);
103 it("should return 2", function() {
104 expect(Ext.Version.getComponentValue("2")).toBe(2);
107 it("should return -5", function() {
108 expect(Ext.Version.getComponentValue("alpha")).toBe(-5);
111 it("should return unknown", function() {
112 expect(Ext.Version.getComponentValue("unknown")).toBe("unknown");
116 describe("compare", function() {
117 it("should return 1", function() {
118 expect(Ext.Version.compare("1.2.3beta", "1.2.2")).toBe(1);
121 it("should return 1", function() {
122 expect(Ext.Version.compare("1.2.3beta", 1)).toBe(1);
125 it("should return -1", function() {
126 expect(Ext.Version.compare("1.2.3beta", 2)).toBe(-1);
129 it("should return -1", function() {
130 expect(Ext.Version.compare("1.2.3beta", "1.2.4")).toBe(-1);
133 it("should return 1", function() {
134 expect(Ext.Version.compare("1.2.3beta", "1.2.3dev")).toBe(1);
137 it("should return 1", function() {
138 expect(Ext.Version.compare("1.2.3beta", "1.2.3alpha")).toBe(1);
141 it("should return 1", function() {
142 expect(Ext.Version.compare("1.2.3beta", "1.2.3a")).toBe(1);
145 it("should return 0", function() {
146 expect(Ext.Version.compare("1.2.3beta", "1.2.3b")).toBe(0);
149 it("should return 0", function() {
150 expect(Ext.Version.compare("1.2.3beta", "1.2.3beta")).toBe(0);
153 it("should return 1", function() {
154 expect(Ext.Version.compare("1.2.3beta", "1.2.3alpha")).toBe(1);
157 it("should return -1", function() {
158 expect(Ext.Version.compare("1.2.3beta", "1.2.3RC")).toBe(-1);
161 it("should return -1", function() {
162 expect(Ext.Version.compare("1.2.3beta", "1.2.3rc")).toBe(-1);
165 it("should return -1", function() {
166 expect(Ext.Version.compare("1.2.3beta", "1.2.3#")).toBe(-1);
169 it("should return -1", function() {
170 expect(Ext.Version.compare("1.2.3beta", "1.2.3pl")).toBe(-1);
173 it("should return -1", function() {
174 expect(Ext.Version.compare("1.2.3beta", "1.2.3p")).toBe(-1);
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");
185 expect(Ext.getVersion("test") instanceof Ext.Version).toBe(true);
189 describe("deprecated Ext.version", function() {
190 it("should be undefined", function() {
191 expect(Ext.version).toBe(undefined);