3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
15 describe("Ext.Version", function() {
16 var version = new Ext.Version("1.2.3beta");
18 describe("toString", function() {
19 it("should cast to string", function() {
20 expect(version+"").toBe("1.2.3beta");
24 describe("getMajor", function() {
25 it("should return 1", function() {
26 expect(version.getMajor()).toBe(1);
30 describe("getMinor", function() {
31 it("should return 2", function() {
32 expect(version.getMinor()).toBe(2);
36 describe("getPatch", function() {
37 it("should return 3", function() {
38 expect(version.getPatch()).toBe(3);
42 describe("getBuild", function() {
43 it("should return 0", function() {
44 expect(version.getBuild()).toBe(0);
48 describe("getRelease", function() {
49 it("should return beta", function() {
50 expect(version.getRelease()).toBe("beta");
54 describe("getShortVersion", function() {
55 it("should return 123", function() {
56 expect(version.getShortVersion()).toBe("123");
60 describe("toArray", function() {
61 it("should return [1, 2, 3, 0, 'beta']", function() {
62 expect(version.toArray()).toEqual([1, 2, 3, 0, 'beta']);
66 describe("isGreaterThan", function() {
67 it("should be greater than 1.2.3alpha", function() {
68 expect(version.isGreaterThan("1.2.3alpha")).toBeTruthy();
70 it("should not be greater than 1.2.3RC", function() {
71 expect(version.isGreaterThan("1.2.3RC")).toBeFalsy();
75 describe("isLessThan", function() {
76 it("should not be smaller than 1.2.3alpha", function() {
77 expect(version.isLessThan("1.2.3alpha")).toBeFalsy();
79 it("should be smaller than 1.2.3RC", function() {
80 expect(version.isLessThan("1.2.3RC")).toBeTruthy();
84 describe("equals", function() {
85 it("should equals 1.2.3beta", function() {
86 expect(version.equals("1.2.3beta")).toBeTruthy();
90 describe("match", function() {
91 it("should match integer 1", function() {
92 expect(version.match(1)).toBeTruthy();
94 it("should match float 1.2", function() {
95 expect(version.match(1.2)).toBeTruthy();
97 it("should match string 1.2.3", function() {
98 expect(version.match("1.2.3")).toBeTruthy();
100 it("should not match string 1.2.3alpha", function() {
101 expect(version.match("1.2.3alpha")).toBeFalsy();
106 describe("Ext.Version Statics", function() {
108 describe("getComponentValue", function() {
109 it("should return 0", function() {
110 expect(Ext.Version.getComponentValue(undefined)).toBe(0);
113 it("should return -2", function() {
114 expect(Ext.Version.getComponentValue(-2)).toBe(-2);
117 it("should return 2", function() {
118 expect(Ext.Version.getComponentValue("2")).toBe(2);
121 it("should return -5", function() {
122 expect(Ext.Version.getComponentValue("alpha")).toBe(-5);
125 it("should return unknown", function() {
126 expect(Ext.Version.getComponentValue("unknown")).toBe("unknown");
130 describe("compare", function() {
131 it("should return 1", function() {
132 expect(Ext.Version.compare("1.2.3beta", "1.2.2")).toBe(1);
135 it("should return 1", function() {
136 expect(Ext.Version.compare("1.2.3beta", 1)).toBe(1);
139 it("should return -1", function() {
140 expect(Ext.Version.compare("1.2.3beta", 2)).toBe(-1);
143 it("should return -1", function() {
144 expect(Ext.Version.compare("1.2.3beta", "1.2.4")).toBe(-1);
147 it("should return 1", function() {
148 expect(Ext.Version.compare("1.2.3beta", "1.2.3dev")).toBe(1);
151 it("should return 1", function() {
152 expect(Ext.Version.compare("1.2.3beta", "1.2.3alpha")).toBe(1);
155 it("should return 1", function() {
156 expect(Ext.Version.compare("1.2.3beta", "1.2.3a")).toBe(1);
159 it("should return 0", function() {
160 expect(Ext.Version.compare("1.2.3beta", "1.2.3b")).toBe(0);
163 it("should return 0", function() {
164 expect(Ext.Version.compare("1.2.3beta", "1.2.3beta")).toBe(0);
167 it("should return 1", function() {
168 expect(Ext.Version.compare("1.2.3beta", "1.2.3alpha")).toBe(1);
171 it("should return -1", function() {
172 expect(Ext.Version.compare("1.2.3beta", "1.2.3RC")).toBe(-1);
175 it("should return -1", function() {
176 expect(Ext.Version.compare("1.2.3beta", "1.2.3rc")).toBe(-1);
179 it("should return -1", function() {
180 expect(Ext.Version.compare("1.2.3beta", "1.2.3#")).toBe(-1);
183 it("should return -1", function() {
184 expect(Ext.Version.compare("1.2.3beta", "1.2.3pl")).toBe(-1);
187 it("should return -1", function() {
188 expect(Ext.Version.compare("1.2.3beta", "1.2.3p")).toBe(-1);
194 describe("Versioning", function() {
195 describe("Ext.setVersion", function() {
196 it("should return an instance of Ext.Version", function() {
197 Ext.setVersion("test", "1.0.1");
199 expect(Ext.getVersion("test") instanceof Ext.Version).toBe(true);
203 describe("deprecated Ext.version", function() {
204 it("should be undefined", function() {
205 expect(Ext.version).toBe(undefined);