forked from angular/angular.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathversion.spec.js
57 lines (43 loc) · 1.67 KB
/
version.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
describe('angular.version', function() {
var version;
beforeEach(function() {
loadFixture('version');
version = browser.driver.executeScript('return angular.version');
});
it('should expose the current version as object', function() {
expect(version).toEqual(jasmine.any(Object));
});
it('should contain property `full` (string)', function() {
expect(version.then(get('full'))).toEqual(jasmine.any(String));
});
it('should contain property `major` (number)', function() {
expect(version.then(get('major'))).toEqual(jasmine.any(Number));
});
it('should contain property `minor` (number)', function() {
expect(version.then(get('minor'))).toEqual(jasmine.any(Number));
});
it('should contain property `dot` (number)', function() {
expect(version.then(get('dot'))).toEqual(jasmine.any(Number));
});
it('should contain property `codeName` (string)', function() {
expect(version.then(get('codeName'))).toEqual(jasmine.any(String));
});
it('should not contain "NG_VERSION_" in `codeName`', function() {
expect(version.then(get('codeName'))).not.toMatch(/NG_VERSION_/);
});
it('\'s `full` property should start with `"major.minor.dot"`', function() {
expect(version.then(validate)).toBe(true);
function validate(ver) {
// We test for "starts with", because `full` is not always equal to `"major.minor.dot"`.
// Possible formats: `1.5.8`, `1.5.0-rc.2`, `1.5.9-build.4949`, `1.5.9-local+sha.859348c`
return ver.full.indexOf([ver.major, ver.minor, ver.dot].join('.')) === 0;
}
});
// Helpers
function get(prop) {
return function getter(obj) {
return obj[prop];
};
}
});