History

Merge pull request #9735 from humbletim/21190-fix-unit-tests

CR 21190 unit_tests: add support for jasmine.done() and pending

Chris Collins committed 9 years ago

Commit d88d52c2 parents 0351ac1 4c0f6a65 files · +49 −8Browse files

Showing the changes to scripts/developer (5 of 5 files). Show all

Unified · Split

5 files
  1. scripts/developer/libraries/jasmine/hifi-boot.js +2 −1
  2. scripts/developer/tests/unit_tests/avatarUnitTests.js +13 −2
  3. scripts/developer/tests/unit_tests/bindUnitTest.js +2 −0
  4. scripts/developer/tests/unit_tests/entityUnitTests.js +11 −1
  5. scripts/developer/tests/unit_tests/testRunner.js +21 −4
scripts/developer/libraries/jasmine/hifi-boot.js+2−1
@@ -20,9 +20,10 @@ · 19 unmodified lines
2020 print('<span style="color:red">Tests completed with ' +
2121 errorCount + ' ' + ERROR + '.<span>');
2222 }
23− if (pending.length)
23+ if (pending.length) {
2424 print ('<span style="color:darkorange">disabled: <br />&nbsp;&nbsp;&nbsp;'+
2525 pending.join('<br />&nbsp;&nbsp;&nbsp;')+'</span>');
26+ }
2627 print('Tests completed in ' + (endTime - startTime) + 'ms.');
2728 };
2829 this.suiteStarted = function(obj) {
scripts/developer/tests/unit_tests/avatarUnitTests.js+13−2
@@ -1,5 +1,7 @@
1+/* eslint-env jasmine */
12
23 // Art3mis
4+// eslint-disable-next-line max-len
35 var DEFAULT_AVATAR_URL = "https://hifi-metaverse.s3-us-west-1.amazonaws.com/marketplace/contents/e76946cc-c272-4adf-9bb6-02cde0a4b57d/8fd984ea6fe1495147a3303f87fa6e23.fst?1460131758";
46
57 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
810
911 describe("MyAvatar", function () {
1012
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+
1122 // reload the avatar from scratch before each test.
1223 beforeEach(function (done) {
1324 MyAvatar.skeletonModelURL = DEFAULT_AVATAR_URL;
@@ -20,12 +31,12 @@ describe("MyAvatar", function () { · 6 unmodified lines
2031 MyAvatar.position = ORIGIN;
2132 MyAvatar.orientation = ROT_IDENT;
2233 // give the avatar 1/2 a second to settle on the ground in the idle pose.
23− Script.setTimeout(function () {
34+ Script.setTimeout(function () {
2435 done();
2536 }, 500);
2637 }
2738 }, 500);
28− });
39+ }, 10000 /* timeout -- allow time to download avatar*/);
2940
3041 // makes the assumption that there is solid ground somewhat underneath the avatar.
3142 it("position and orientation getters", function () {
scripts/developer/tests/unit_tests/bindUnitTest.js+2−0
@@ -1,3 +1,5 @@
1+/* eslint-env jasmine */
2+
13 Script.include('../../../system/libraries/utils.js');
24
35 describe('Bind', function() {
scripts/developer/tests/unit_tests/entityUnitTests.js+11−1
@@ -1,3 +1,5 @@
1+/* eslint-env jasmine */
2+
13 describe('Entity', function() {
24 var center = Vec3.sum(
35 MyAvatar.position,
@@ -19,6 +21,14 @@ describe('Entity', function() { · 15 unmodified lines
1921 },
2022 };
2123
24+ it('serversExist', function() {
25+ expect(Entities.serversExist()).toBe(true);
26+ });
27+
28+ it('canRezTmp', function() {
29+ expect(Entities.canRezTmp()).toBe(true);
30+ });
31+
2232 beforeEach(function() {
2333 boxEntity = Entities.addEntity(boxProps);
2434 });
@@ -62,4 +72,4 @@ describe('Entity', function() { · 37 unmodified lines
6272 props = Entities.getEntityProperties(boxEntity);
6373 expect(props.lastEdited).toBeGreaterThan(prevLastEdited);
6474 });
65−});
75+});
scripts/developer/tests/unit_tests/testRunner.js+21−4
@@ -1,13 +1,30 @@
1+/* eslint-env jasmine */
2+
13 // Include testing library
24 Script.include('../../libraries/jasmine/jasmine.js');
3−Script.include('../../libraries/jasmine/hifi-boot.js')
5+Script.include('../../libraries/jasmine/hifi-boot.js');
46
57 // Include unit tests
6−// FIXME: Figure out why jasmine done() is not working.
7−// Script.include('avatarUnitTests.js');
8+Script.include('avatarUnitTests.js');
89 Script.include('bindUnitTest.js');
910 Script.include('entityUnitTests.js');
1011
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+
1129 // Run the tests
1230 jasmine.getEnv().execute();
13−Script.stop();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t