mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 12:04:03 +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
|
@ -20,9 +20,10 @@
|
||||||
print('<span style="color:red">Tests completed with ' +
|
print('<span style="color:red">Tests completed with ' +
|
||||||
errorCount + ' ' + ERROR + '.<span>');
|
errorCount + ' ' + ERROR + '.<span>');
|
||||||
}
|
}
|
||||||
if (pending.length)
|
if (pending.length) {
|
||||||
print ('<span style="color:darkorange">disabled: <br /> '+
|
print ('<span style="color:darkorange">disabled: <br /> '+
|
||||||
pending.join('<br /> ')+'</span>');
|
pending.join('<br /> ')+'</span>');
|
||||||
|
}
|
||||||
print('Tests completed in ' + (endTime - startTime) + 'ms.');
|
print('Tests completed in ' + (endTime - startTime) + 'ms.');
|
||||||
};
|
};
|
||||||
this.suiteStarted = function(obj) {
|
this.suiteStarted = function(obj) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
/* eslint-env jasmine */
|
||||||
|
|
||||||
// Art3mis
|
// 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 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};
|
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 () {
|
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.
|
// reload the avatar from scratch before each test.
|
||||||
beforeEach(function (done) {
|
beforeEach(function (done) {
|
||||||
MyAvatar.skeletonModelURL = DEFAULT_AVATAR_URL;
|
MyAvatar.skeletonModelURL = DEFAULT_AVATAR_URL;
|
||||||
|
@ -20,12 +31,12 @@ describe("MyAvatar", function () {
|
||||||
MyAvatar.position = ORIGIN;
|
MyAvatar.position = ORIGIN;
|
||||||
MyAvatar.orientation = ROT_IDENT;
|
MyAvatar.orientation = ROT_IDENT;
|
||||||
// give the avatar 1/2 a second to settle on the ground in the idle pose.
|
// give the avatar 1/2 a second to settle on the ground in the idle pose.
|
||||||
Script.setTimeout(function () {
|
Script.setTimeout(function () {
|
||||||
done();
|
done();
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
}, 10000 /* timeout -- allow time to download avatar*/);
|
||||||
|
|
||||||
// makes the assumption that there is solid ground somewhat underneath the avatar.
|
// makes the assumption that there is solid ground somewhat underneath the avatar.
|
||||||
it("position and orientation getters", function () {
|
it("position and orientation getters", function () {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-env jasmine */
|
||||||
|
|
||||||
Script.include('../../../system/libraries/utils.js');
|
Script.include('../../../system/libraries/utils.js');
|
||||||
|
|
||||||
describe('Bind', function() {
|
describe('Bind', function() {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-env jasmine */
|
||||||
|
|
||||||
describe('Entity', function() {
|
describe('Entity', function() {
|
||||||
var center = Vec3.sum(
|
var center = Vec3.sum(
|
||||||
MyAvatar.position,
|
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() {
|
beforeEach(function() {
|
||||||
boxEntity = Entities.addEntity(boxProps);
|
boxEntity = Entities.addEntity(boxProps);
|
||||||
});
|
});
|
||||||
|
@ -62,4 +72,4 @@ describe('Entity', function() {
|
||||||
props = Entities.getEntityProperties(boxEntity);
|
props = Entities.getEntityProperties(boxEntity);
|
||||||
expect(props.lastEdited).toBeGreaterThan(prevLastEdited);
|
expect(props.lastEdited).toBeGreaterThan(prevLastEdited);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,30 @@
|
||||||
|
/* eslint-env jasmine */
|
||||||
|
|
||||||
// Include testing library
|
// Include testing library
|
||||||
Script.include('../../libraries/jasmine/jasmine.js');
|
Script.include('../../libraries/jasmine/jasmine.js');
|
||||||
Script.include('../../libraries/jasmine/hifi-boot.js')
|
Script.include('../../libraries/jasmine/hifi-boot.js');
|
||||||
|
|
||||||
// Include unit tests
|
// 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('bindUnitTest.js');
|
||||||
Script.include('entityUnitTests.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
|
// Run the tests
|
||||||
jasmine.getEnv().execute();
|
jasmine.getEnv().execute();
|
||||||
Script.stop();
|
|
||||||
|
|
Loading…
Reference in a new issue