mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 19:55:28 +02:00
Merge pull request #9735 from humbletim/21190-fix-unit-tests
CR 21190 unit_tests: add support for jasmine.done() and pending
This commit is contained in:
commit
d88d52cd2e
5 changed files with 49 additions and 8 deletions
scripts/developer
libraries/jasmine
tests/unit_tests
|
@ -20,9 +20,10 @@
|
|||
print('<span style="color:red">Tests completed with ' +
|
||||
errorCount + ' ' + ERROR + '.<span>');
|
||||
}
|
||||
if (pending.length)
|
||||
if (pending.length) {
|
||||
print ('<span style="color:darkorange">disabled: <br /> '+
|
||||
pending.join('<br /> ')+'</span>');
|
||||
}
|
||||
print('Tests completed in ' + (endTime - startTime) + 'ms.');
|
||||
};
|
||||
this.suiteStarted = function(obj) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/* eslint-env jasmine */
|
||||
|
||||
// Art3mis
|
||||
// eslint-disable-next-line max-len
|
||||
var DEFAULT_AVATAR_URL = "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/contents/e76946cc-c272-4adf-9bb6-02cde0a4b57d/8fd984ea6fe1495147a3303f87fa6e23.fst?1460131758";
|
||||
|
||||
var ORIGIN = {x: 0, y: 0, z: 0};
|
||||
|
@ -8,6 +10,15 @@ var ROT_IDENT = {x: 0, y: 0, z: 0, w: 1};
|
|||
|
||||
describe("MyAvatar", function () {
|
||||
|
||||
// backup/restore current skeletonModelURL
|
||||
beforeAll(function() {
|
||||
this.oldURL = MyAvatar.skeletonModelURL;
|
||||
});
|
||||
|
||||
afterAll(function() {
|
||||
MyAvatar.skeletonModelURL = this.oldURL;
|
||||
});
|
||||
|
||||
// reload the avatar from scratch before each test.
|
||||
beforeEach(function (done) {
|
||||
MyAvatar.skeletonModelURL = DEFAULT_AVATAR_URL;
|
||||
|
@ -20,12 +31,12 @@ describe("MyAvatar", function () {
|
|||
MyAvatar.position = ORIGIN;
|
||||
MyAvatar.orientation = ROT_IDENT;
|
||||
// give the avatar 1/2 a second to settle on the ground in the idle pose.
|
||||
Script.setTimeout(function () {
|
||||
Script.setTimeout(function () {
|
||||
done();
|
||||
}, 500);
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
}, 10000 /* timeout -- allow time to download avatar*/);
|
||||
|
||||
// makes the assumption that there is solid ground somewhat underneath the avatar.
|
||||
it("position and orientation getters", function () {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* eslint-env jasmine */
|
||||
|
||||
Script.include('../../../system/libraries/utils.js');
|
||||
|
||||
describe('Bind', function() {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* eslint-env jasmine */
|
||||
|
||||
describe('Entity', function() {
|
||||
var center = Vec3.sum(
|
||||
MyAvatar.position,
|
||||
|
@ -19,6 +21,14 @@ describe('Entity', function() {
|
|||
},
|
||||
};
|
||||
|
||||
it('serversExist', function() {
|
||||
expect(Entities.serversExist()).toBe(true);
|
||||
});
|
||||
|
||||
it('canRezTmp', function() {
|
||||
expect(Entities.canRezTmp()).toBe(true);
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
boxEntity = Entities.addEntity(boxProps);
|
||||
});
|
||||
|
@ -62,4 +72,4 @@ describe('Entity', function() {
|
|||
props = Entities.getEntityProperties(boxEntity);
|
||||
expect(props.lastEdited).toBeGreaterThan(prevLastEdited);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,13 +1,30 @@
|
|||
/* eslint-env jasmine */
|
||||
|
||||
// Include testing library
|
||||
Script.include('../../libraries/jasmine/jasmine.js');
|
||||
Script.include('../../libraries/jasmine/hifi-boot.js')
|
||||
Script.include('../../libraries/jasmine/hifi-boot.js');
|
||||
|
||||
// Include unit tests
|
||||
// FIXME: Figure out why jasmine done() is not working.
|
||||
// Script.include('avatarUnitTests.js');
|
||||
Script.include('avatarUnitTests.js');
|
||||
Script.include('bindUnitTest.js');
|
||||
Script.include('entityUnitTests.js');
|
||||
|
||||
describe("jasmine internal tests", function() {
|
||||
it('should support async .done()', function(done) {
|
||||
var start = new Date;
|
||||
Script.setTimeout(function() {
|
||||
expect((new Date - start)/1000).toBeCloseTo(0.5, 1);
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
// jasmine pending test
|
||||
xit('disabled test', function() {
|
||||
expect(false).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
// invoke Script.stop (after any async tests complete)
|
||||
jasmine.getEnv().addReporter({ jasmineDone: Script.stop });
|
||||
|
||||
// Run the tests
|
||||
jasmine.getEnv().execute();
|
||||
Script.stop();
|
||||
|
|
Loading…
Reference in a new issue