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