CR 21190 unit_tests: add support for jasmine.done() and pending
Showing the changes to scripts/developer (5 of 5 files). Show all
Unified · Split
| @@ -20,9 +20,10 @@ · 19 unmodified lines | |||
| 20 | print('<span style="color:red">Tests completed with ' + | 20 | print('<span style="color:red">Tests completed with ' + |
| 21 | errorCount + ' ' + ERROR + '.<span>'); | 21 | errorCount + ' ' + ERROR + '.<span>'); |
| 22 | } | 22 | } |
| 23 | if (pending.length) | 23 | if (pending.length) { |
| 24 | print ('<span style="color:darkorange">disabled: <br /> '+ | 24 | print ('<span style="color:darkorange">disabled: <br /> '+ |
| 25 | pending.join('<br /> ')+'</span>'); | 25 | pending.join('<br /> ')+'</span>'); |
| 26 | } | ||
| 26 | print('Tests completed in ' + (endTime - startTime) + 'ms.'); | 27 | print('Tests completed in ' + (endTime - startTime) + 'ms.'); |
| 27 | }; | 28 | }; |
| 28 | this.suiteStarted = function(obj) { | 29 | this.suiteStarted = function(obj) { |
| @@ -1,5 +1,7 @@ | |||
| 1 | /* eslint-env jasmine */ | ||
| 1 | 2 | ||
| 2 | // Art3mis | 3 | // Art3mis |
| 4 | // eslint-disable-next-line max-len | ||
| 3 | var DEFAULT_AVATAR_URL = "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/contents/e76946cc-c272-4adf-9bb6-02cde0a4b57d/8fd984ea6fe1495147a3303f87fa6e23.fst?1460131758"; | 5 | var DEFAULT_AVATAR_URL = "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/contents/e76946cc-c272-4adf-9bb6-02cde0a4b57d/8fd984ea6fe1495147a3303f87fa6e23.fst?1460131758"; |
| 4 | 6 | ||
| 5 | var ORIGIN = {x: 0, y: 0, z: 0}; | 7 | var ORIGIN = {x: 0, y: 0, z: 0}; |
| @@ -8,6 +10,15 @@ var ROT_IDENT = {x: 0, y: 0, z: 0, w: 1}; · 2 unmodified lines | |||
| 8 | 10 | ||
| 9 | describe("MyAvatar", function () { | 11 | describe("MyAvatar", function () { |
| 10 | 12 | ||
| 13 | // backup/restore current skeletonModelURL | ||
| 14 | beforeAll(function() { | ||
| 15 | this.oldURL = MyAvatar.skeletonModelURL; | ||
| 16 | }); | ||
| 17 | |||
| 18 | afterAll(function() { | ||
| 19 | MyAvatar.skeletonModelURL = this.oldURL; | ||
| 20 | }); | ||
| 21 | |||
| 11 | // reload the avatar from scratch before each test. | 22 | // reload the avatar from scratch before each test. |
| 12 | beforeEach(function (done) { | 23 | beforeEach(function (done) { |
| 13 | MyAvatar.skeletonModelURL = DEFAULT_AVATAR_URL; | 24 | MyAvatar.skeletonModelURL = DEFAULT_AVATAR_URL; |
| @@ -20,12 +31,12 @@ describe("MyAvatar", function () { · 6 unmodified lines | |||
| 20 | MyAvatar.position = ORIGIN; | 31 | MyAvatar.position = ORIGIN; |
| 21 | MyAvatar.orientation = ROT_IDENT; | 32 | MyAvatar.orientation = ROT_IDENT; |
| 22 | // give the avatar 1/2 a second to settle on the ground in the idle pose. | 33 | // give the avatar 1/2 a second to settle on the ground in the idle pose. |
| 23 | Script.setTimeout(function () { | 34 | Script.setTimeout(function () { |
| 24 | done(); | 35 | done(); |
| 25 | }, 500); | 36 | }, 500); |
| 26 | } | 37 | } |
| 27 | }, 500); | 38 | }, 500); |
| 28 | }); | 39 | }, 10000 /* timeout -- allow time to download avatar*/); |
| 29 | 40 | ||
| 30 | // makes the assumption that there is solid ground somewhat underneath the avatar. | 41 | // makes the assumption that there is solid ground somewhat underneath the avatar. |
| 31 | it("position and orientation getters", function () { | 42 | it("position and orientation getters", function () { |
| @@ -1,3 +1,5 @@ | |||
| 1 | /* eslint-env jasmine */ | ||
| 2 | |||
| 1 | Script.include('../../../system/libraries/utils.js'); | 3 | Script.include('../../../system/libraries/utils.js'); |
| 2 | 4 | ||
| 3 | describe('Bind', function() { | 5 | describe('Bind', function() { |
| @@ -1,3 +1,5 @@ | |||
| 1 | /* eslint-env jasmine */ | ||
| 2 | |||
| 1 | describe('Entity', function() { | 3 | describe('Entity', function() { |
| 2 | var center = Vec3.sum( | 4 | var center = Vec3.sum( |
| 3 | MyAvatar.position, | 5 | MyAvatar.position, |
| @@ -19,6 +21,14 @@ describe('Entity', function() { · 15 unmodified lines | |||
| 19 | }, | 21 | }, |
| 20 | }; | 22 | }; |
| 21 | 23 | ||
| 24 | it('serversExist', function() { | ||
| 25 | expect(Entities.serversExist()).toBe(true); | ||
| 26 | }); | ||
| 27 | |||
| 28 | it('canRezTmp', function() { | ||
| 29 | expect(Entities.canRezTmp()).toBe(true); | ||
| 30 | }); | ||
| 31 | |||
| 22 | beforeEach(function() { | 32 | beforeEach(function() { |
| 23 | boxEntity = Entities.addEntity(boxProps); | 33 | boxEntity = Entities.addEntity(boxProps); |
| 24 | }); | 34 | }); |
| @@ -62,4 +72,4 @@ describe('Entity', function() { · 37 unmodified lines | |||
| 62 | props = Entities.getEntityProperties(boxEntity); | 72 | props = Entities.getEntityProperties(boxEntity); |
| 63 | expect(props.lastEdited).toBeGreaterThan(prevLastEdited); | 73 | expect(props.lastEdited).toBeGreaterThan(prevLastEdited); |
| 64 | }); | 74 | }); |
| 65 | }); | 75 | }); |
| @@ -1,13 +1,30 @@ | |||
| 1 | /* eslint-env jasmine */ | ||
| 2 | |||
| 1 | // Include testing library | 3 | // Include testing library |
| 2 | Script.include('../../libraries/jasmine/jasmine.js'); | 4 | Script.include('../../libraries/jasmine/jasmine.js'); |
| 3 | Script.include('../../libraries/jasmine/hifi-boot.js') | 5 | Script.include('../../libraries/jasmine/hifi-boot.js'); |
| 4 | 6 | ||
| 5 | // Include unit tests | 7 | // Include unit tests |
| 6 | // FIXME: Figure out why jasmine done() is not working. | 8 | Script.include('avatarUnitTests.js'); |
| 7 | // Script.include('avatarUnitTests.js'); | ||
| 8 | Script.include('bindUnitTest.js'); | 9 | Script.include('bindUnitTest.js'); |
| 9 | Script.include('entityUnitTests.js'); | 10 | Script.include('entityUnitTests.js'); |
| 10 | 11 | ||
| 12 | describe("jasmine internal tests", function() { | ||
| 13 | it('should support async .done()', function(done) { | ||
| 14 | var start = new Date; | ||
| 15 | Script.setTimeout(function() { | ||
| 16 | expect((new Date - start)/1000).toBeCloseTo(0.5, 1); | ||
| 17 | done(); | ||
| 18 | }, 500); | ||
| 19 | }); | ||
| 20 | // jasmine pending test | ||
| 21 | xit('disabled test', function() { | ||
| 22 | expect(false).toBe(true); | ||
| 23 | }); | ||
| 24 | }); | ||
| 25 | |||
| 26 | // invoke Script.stop (after any async tests complete) | ||
| 27 | jasmine.getEnv().addReporter({ jasmineDone: Script.stop }); | ||
| 28 | |||
| 11 | // Run the tests | 29 | // Run the tests |
| 12 | jasmine.getEnv().execute(); | 30 | jasmine.getEnv().execute(); |
| 13 | Script.stop(); | ||