From 2935f93d6cef73e70983e8c493358683c60194d9 Mon Sep 17 00:00:00 2001 From: Maia Hansen Date: Thu, 4 Mar 2021 18:42:30 -0800 Subject: [PATCH 1/2] No ticket: tests directory is breaking the node build --- tests/README.md | 19 - tests/integration/rest.integration.test.ts | 374 ------------------ tests/integration/secrets/auth_example.json | 32 -- .../testUtilities/integrationTestUtils.ts | 71 ---- .../src/classes/HiFiAudioAPIData.unit.test.ts | 61 --- .../src/classes/HiFiCommunicator.unit.test.ts | 8 - .../src/classes/HiFiMixerSession.unit.test.ts | 6 - .../src/utilities/HiFiLogger.unit.test.ts | 12 - tests/unit/testUtilities/globalTeardown.js | 5 - 9 files changed, 588 deletions(-) delete mode 100644 tests/README.md delete mode 100644 tests/integration/rest.integration.test.ts delete mode 100644 tests/integration/secrets/auth_example.json delete mode 100644 tests/integration/testUtilities/integrationTestUtils.ts delete mode 100644 tests/unit/src/classes/HiFiAudioAPIData.unit.test.ts delete mode 100644 tests/unit/src/classes/HiFiCommunicator.unit.test.ts delete mode 100644 tests/unit/src/classes/HiFiMixerSession.unit.test.ts delete mode 100644 tests/unit/src/utilities/HiFiLogger.unit.test.ts delete mode 100644 tests/unit/testUtilities/globalTeardown.js diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index b85cfbf0..00000000 --- a/tests/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# JEST AUTOMATED TESTING INFO -To run all tests, type `jest test` into the console. - -## Unit Testing - -To run only unit tests, type `jest unit` into the console. - -...coming soon - -## Integration Testing - -To run only integration tests, type `jest integration` into the console. - -### Secrets and Account Setup -Since integration tests require actual server connections (as opposed to mock functions and connections), -you will need to set up an account with some preset apps and spaces and a way to access private data -to test with. The tests will use specific names, IDs, secrets, and URLs, so create a copy of `auth.example.json` -named `auth.json` in your `secrets` folder and then replace the data to match your own account. Your -'stackData.url' will be the root URL of your account. \ No newline at end of file diff --git a/tests/integration/rest.integration.test.ts b/tests/integration/rest.integration.test.ts deleted file mode 100644 index 251f5876..00000000 --- a/tests/integration/rest.integration.test.ts +++ /dev/null @@ -1,374 +0,0 @@ -const fetch = require('node-fetch'); -import { TOKEN_GEN_TYPES, generateJWT } from './testUtilities/integrationTestUtils'; -const stackData = require('./secrets/auth.json').stackData; -const stackURL = stackData.url; - -//TODO Any of the above (delete, change / get settings, ignore / don't ignore signing) should all FAIL if the admin JWT being used is for an application that is NOT the application the space is in. (This test will fail -- i.e. the action will succeed -- right now! Yikes!!) -describe('HiFi API REST Calls', () => { - let adminToken: string; - let nonAdminToken: string; - - beforeAll(async () => { - try { - adminToken = await generateJWT(TOKEN_GEN_TYPES.ADMIN_ID_APP1_SPACE1_SIGNED); - nonAdminToken = await generateJWT(TOKEN_GEN_TYPES.NON_ADMIN_ID_APP1_SPACE1_SIGNED); - } catch (err) { - console.error("Unable to create non admin token for testing REST calls. ERR: ", err); - return; - } - }); - - describe('Admin CAN create and delete a space', () => { - let newSpaceName = "newSpace"; - let createdSpaceJSON: any = {}; - test(`CAN create a space`, async () => { - // TODO ensure space does not already exist - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/create?token=${adminToken}&name=${newSpaceName}`); - createdSpaceJSON = await returnMessage.json(); - expect(createdSpaceJSON['space-id']).toBeDefined(); - expect(createdSpaceJSON['app-id']).toBe(stackData.apps.app1.id); - }); - - test(`CAN delete a space`, async () => { - // TODO ensure space already exists - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${createdSpaceJSON['space-id']}?token=${adminToken}`, { - method: 'DELETE' - }); - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON['space-id']).toBe(returnMessageJSON['space-id']); - expect(returnMessageJSON['app-id']).toBe(stackData.apps.app1.id); - }); - }); - - describe('NonAdmin CANNOT create or delete a space', () => { - let newSpaceName = "someNewSpace"; - test(`Create a space`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/create?token=${nonAdminToken}&name=${newSpaceName}`) - let returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CAN delete a space`, async () => { - let spaceToDelete: string; - try { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/create?token=${adminToken}&name=${newSpaceName}`); - let createdSpaceJSON = await returnMessage.json(); - spaceToDelete = createdSpaceJSON['space-id']; - } catch (err) { - console.log("Cannot set up a space to test a nonadmin trying to delete a space! ERR: ", err); - } - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${spaceToDelete}?token=${nonAdminToken}`, { - method: 'DELETE' - }); - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - try { - await fetch(`${stackURL}/api/v1/spaces/${spaceToDelete}?token=${adminToken}`, { - method: 'DELETE' - }); - } catch (err) { - console.log("Cannot delete the space used to test a nonadmin trying to delete a space! ERR: ", err); - } - }); - }); - - describe(`Admin CAN read settings for a space`, () => { - test(`CAN read all space settings simultaneously`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - expect(settingsJSON['app-id']).toBeDefined(); - expect(settingsJSON['space-id']).toBeDefined(); - expect(settingsJSON['ignore-token-signing']).toBeDefined(); - expect(settingsJSON['name']).toBeDefined(); - expect(settingsJSON['new-connections-allowed']).toBeDefined(); - }); - - test(`CAN read the 'space-id' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/space-id/?token=${adminToken}`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - expect(settingsJSON['space-id']).toBeDefined(); - }); - - test(`CAN read the 'app-id' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/app-id/?token=${adminToken}`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - expect(settingsJSON['app-id']).toBeDefined(); - }); - - test(`CAN read the 'ignore-token-signing' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/ignore-token-signing/?token=${adminToken}`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - expect(settingsJSON['ignore-token-signing']).toBeDefined(); - }); - - test(`CAN read the 'name' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/name/?token=${adminToken}`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - expect(settingsJSON['name']).toBeDefined(); - }); - - test(`CAN read the 'new-connections-allowed' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/new-connections-allowed/?token=${adminToken}`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - expect(settingsJSON['new-connections-allowed']).toBeDefined(); - }); - }); - - describe(`Non admin CANNOT read settings for a space`, () => { - test(`CANNOT read all space settings simultaneously`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${nonAdminToken}`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT read the 'space-id' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/space-id/?token=${nonAdminToken}`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT read the 'app-id' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/app-id/?token=${nonAdminToken}`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT read the 'ignore-token-signing' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/ignore-token-signing/?token=${nonAdminToken}`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT read the 'name' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/name/?token=${nonAdminToken}`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT read the 'new-connections-allowed' setting`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings/new-connections-allowed/?token=${nonAdminToken}`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - }); - - describe('Admin CAN change space settings', () => { - test(`CAN change multiple settings simultaneously using 'GET'`, async () => { - // preset the property to ensure its state before attempting to make changes - try { - await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&new-connections-allowed=true`); - } catch (err) { - console.log("Cannot set space to allow unsigned tokens signing before testing."); - throw err; - } - let newName = "nameChanged"; - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&new-connections-allowed=false&name=${newName}`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - - expect(settingsJSON['new-connections-allowed']).toBe(false); - expect(settingsJSON['name']).toBe(newName); - }); - - test(`CAN change multiple settings simultaneously using 'POST'`, async () => { - // preset the property to ensure its state before attempting to make changes - try { - await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&new-connections-allowed=false`); - } catch (err) { - console.log("Cannot set space to allow unsigned tokens signing before testing."); - throw err; - } - let newName = "nameChangedAlso"; - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - 'name': newName, - 'new-connections-allowed': true - }) - }); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - - expect(settingsJSON['new-connections-allowed']).toBe(true); - expect(settingsJSON['name']).toBe(newName); - }); - - test(`CAN make a space not joinable`, async () => { - // preset the property to ensure its state before attempting to change it - try { - await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&new-connections-allowed=true`); - } catch (err) { - console.log("Cannot make space joinable before testing."); - throw err; - } - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&new-connections-allowed=false`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - - expect(settingsJSON['new-connections-allowed']).toBe(false); - - }); - - test(`CAN make a space joinable`, async () => { - // preset the property to ensure its state before attempting to change it - try { - await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&new-connections-allowed=false`); - } catch (err) { - console.log("Cannot make space not joinable before testing."); - throw err; - } - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&new-connections-allowed=true`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - - expect(settingsJSON['new-connections-allowed']).toBe(true); - }); - - test(`CAN change the space name`, async () => { - let newName = "changed name"; - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&name=${newName}`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - - expect(settingsJSON['name']).toBe(newName); - - // restore name to default - returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&name=${stackData.apps.app1.spaces.space1.name}`); - }); - - test(`CAN set space to allow unsigned tokens`, async () => { - // preset the property to ensure its state before attempting to change it - try { - await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&ignore-token-signing=false`); - } catch (err) { - console.log("Cannot set space to disallow unsigned tokens before testing."); - throw err; - } - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&ignore-token-signing=true`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - expect(settingsJSON['ignore-token-signing']).toBe(true); - }); - - test(`CAN set space to disallow unsigned tokens`, async () => { - // preset the property to ensure its state before attempting to change it - try { - await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&ignore-token-signing=true`); - } catch (err) { - console.log("Cannot set space to allow unsigned tokens signing before testing."); - throw err; - } - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${adminToken}&ignore-token-signing=false`); - - let settingsJSON: any = {}; - settingsJSON = await returnMessage.json(); - expect(settingsJSON['ignore-token-signing']).toBe(false); - }); - }); - - describe('Non admin CANNOT change space settings', () => { - test(`CANNOT change multiple settings simultaneously using 'GET'`, async () => { - let newName = "nameChangedAgain"; - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${nonAdminToken}&new-connections-allowed=false&name=${newName}`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT change multiple settings simultaneously using 'POST'`, async () => { - let newName = "nameChangedAgain"; - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${nonAdminToken}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - 'name': newName, - 'new-connections-allowed': true - }) - }); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT make a space not joinable`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${nonAdminToken}&new-connections-allowed=false`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - - }); - - test(`CANNOT make a space joinable`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${nonAdminToken}&new-connections-allowed=true`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT change the space name`, async () => { - let newName = "changed name"; - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${nonAdminToken}&name=${newName}`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT set space to ignore token signing`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${nonAdminToken}&ignore-token-signing=true`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - - test(`CANNOT set space to not ignore token signing`, async () => { - let returnMessage = await fetch(`${stackURL}/api/v1/spaces/${stackData.apps.app1.spaces.space1.id}/settings?token=${nonAdminToken}&ignore-token-signing=false`); - - let returnMessageJSON: any = {}; - returnMessageJSON = await returnMessage.json(); - expect(returnMessageJSON.error).toBe("token isn't an admin token"); - }); - }); -}); \ No newline at end of file diff --git a/tests/integration/secrets/auth_example.json b/tests/integration/secrets/auth_example.json deleted file mode 100644 index 41e3329c..00000000 --- a/tests/integration/secrets/auth_example.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "stackData": { - "name": "", - "url": "", - "apps": { - "app1": { - "name": "Staging_QA_App_1", - "id": "aaaaaaaa-1111-bbbb-2222-cccccccccccc", - "secret": "aaaaaaaa-1111-bbbb-2222-cccccccccccc", - "spaces": { - "space1": { - "name": "Staging_QA_App_1_Space_1", - "id": "aaaaaaaa-1111-bbbb-2222-cccccccccccc" - }, - "nonexistant": { - "name": "Nonexistant", - "id": "aaaaaaaa-1111-bbbb-2222-cccccccccccc" - } - } - }, - "app2": { - "name": "Staging_QA_App_2", - "id": "aaaaaaaa-1111-bbbb-2222-cccccccccccc", - "secret": "aaaaaaaa-1111-bbbb-2222-cccccccccccc", - "spaces": { - "name": "Staging_QA_App_2_Space_2", - "id": "aaaaaaaa-1111-bbbb-2222-cccccccccccc" - } - } - } - } -} \ No newline at end of file diff --git a/tests/integration/testUtilities/integrationTestUtils.ts b/tests/integration/testUtilities/integrationTestUtils.ts deleted file mode 100644 index 38910434..00000000 --- a/tests/integration/testUtilities/integrationTestUtils.ts +++ /dev/null @@ -1,71 +0,0 @@ -const { default: SignedJWT } = require('jose/jwt/sign'); -const { default: UnsecuredJWT } = require('jose/jwt/unsecured'); -const crypto = require('crypto'); -const stackData = require('../secrets/auth.json').stackData; - -export const TOKEN_GEN_TYPES = { - "ADMIN_ID_APP1_SPACE1_SIGNED": { - "admin": true, - "signed": true, - "user_id": "qateamAdmin", - "app_id": stackData.apps.app1.id, - "space_id": stackData.apps.app1.spaces.space1.id, - "app_secret": stackData.apps.app1.secret - }, - "NON_ADMIN_ID_APP1_SPACE1_SIGNED": { - "admin": false, - "signed": true, - "user_id": "qateamNonAdmin", - "app_id": stackData.apps.app1.id, - "space_id": stackData.apps.app1.spaces.space1.id, - "app_secret": stackData.apps.app1.secret - }, - "NON_ADMIN_ID_APP1_SPACE1_UNSIGNED": { - "admin": false, - "signed": false, - "user_id": "qateamNonAdmin", - "app_id": stackData.apps.app1.id, - "space_id": stackData.apps.app1.spaces.space1.id, - "app_secret": stackData.apps.app1.secret - }, - "NON_ADMIN_APP1_SPACE_ID_NONEXISTANT_SIGNED": { - "admin": false, - "signed": true, - "user_id": "qateamNonAdmin", - "app_id": stackData.apps.app1.id, - "space_id": stackData.apps.app1.spaces.nonexistant.id, - "app_secret": stackData.apps.app1.secret - }, - "NON_ADMIN_APP1_SPACE_NAME_NONEXISTANT_SIGNED": { - "admin": false, - "signed": true, - "user_id": "qateamNonAdmin", - "app_id": stackData.apps.app1.id, - "space_name": "stackData.apps.app1.spaces.nonexistant.name", - "app_secret": stackData.apps.app1.secret - } -}; - -export async function generateJWT(tokenType: { [property: string]: any }) { - const SECRET_KEY_FOR_SIGNING = crypto.createSecretKey(Buffer.from(tokenType.app_secret, "utf8")); - try { - let data: any = {}; - data = { - "user_id": tokenType.user_id, - "app_id": tokenType.app_id - }; - if (tokenType.admin) data.admin = tokenType.admin; - if (tokenType.space_id) data.space_id = tokenType.space_id; - if (tokenType.space_name) data.space_name = tokenType.space_name; - if (tokenType.signed) { - return await new SignedJWT(data) - .setProtectedHeader({ alg: 'HS256', typ: 'JWT' }) - .sign(SECRET_KEY_FOR_SIGNING); - } else { - return await new UnsecuredJWT(data).encode(); - } - } catch (error) { - console.error(`Couldn't create JWT! Error:\n${error}`); - return; - } -} \ No newline at end of file diff --git a/tests/unit/src/classes/HiFiAudioAPIData.unit.test.ts b/tests/unit/src/classes/HiFiAudioAPIData.unit.test.ts deleted file mode 100644 index 51576c2b..00000000 --- a/tests/unit/src/classes/HiFiAudioAPIData.unit.test.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { HiFiAudioAPIData, OrientationEuler3D, Point3D } from "../../../../src/classes/HiFiAudioAPIData"; - -describe('Point3D', () => { - test('verifies default members of a new Point3D are null', () => { - let newPoint3D = new Point3D(); - expect(newPoint3D.x).toBeNull(); - expect(newPoint3D.y).toBeNull(); - expect(newPoint3D.z).toBeNull(); - }); - - test('allows us to only set the x component of a new Point3D', () => { - let newPoint3D = new Point3D({x: 5}); - expect(newPoint3D.x).toBe(5); - expect(newPoint3D.y).toBeNull(); - expect(newPoint3D.z).toBeNull(); - }); -}); - -describe('OrientationEuler3D', () => { - test('verifies default members of a new OrientationEuler3D are 0', () => { - let newOrientationEuler3D = new OrientationEuler3D(); - expect(newOrientationEuler3D.pitchDegrees).toBe(0); - expect(newOrientationEuler3D.yawDegrees).toBe(0); - expect(newOrientationEuler3D.rollDegrees).toBe(0); - }); - - test('allows us to only set the pitchDegrees component of a new OrientationEuler3D', () => { - let newOrientationEuler3D = new OrientationEuler3D({pitchDegrees: 25}); - expect(newOrientationEuler3D.pitchDegrees).toBe(25); - expect(newOrientationEuler3D.yawDegrees).toBe(0); - expect(newOrientationEuler3D.rollDegrees).toBe(0); - }); -}); - -describe('HiFiAudioAPIData', () => { - test('verifies default members of a new HiFiAudioAPIData are null', () => { - let newHiFiAudioAPIData = new HiFiAudioAPIData(); - expect(newHiFiAudioAPIData.position).toBeNull(); - expect(newHiFiAudioAPIData.orientationEuler).toBeNull(); - expect(newHiFiAudioAPIData.orientationQuat).toBeNull(); - }); - - test('the HiFiAudioAPIData.diff() function', () => { - let data1 = new HiFiAudioAPIData({ - position: new Point3D({x: 0, y: 4}) - }); - let data2 = new HiFiAudioAPIData(); - - let diff1 = data1.diff(data2); - expect(diff1.position).toBeNull(); - expect(diff1.orientationEuler).toBeNull(); - expect(diff1.orientationQuat).toBeNull(); - - let diff2 = data2.diff(data1); - expect(diff2.position.x).toBe(0); - expect(diff2.position.y).toBe(4); - expect(diff2.position.z).toBeNull(); - expect(diff2.orientationEuler).toBeNull(); - expect(diff2.orientationQuat).toBeNull(); - }); -}); \ No newline at end of file diff --git a/tests/unit/src/classes/HiFiCommunicator.unit.test.ts b/tests/unit/src/classes/HiFiCommunicator.unit.test.ts deleted file mode 100644 index a3367e0d..00000000 --- a/tests/unit/src/classes/HiFiCommunicator.unit.test.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { HiFiCommunicator } from "../../../../src/classes/HiFiCommunicator"; -import { HiFiConstants } from "../../../../src/constants/HiFiConstants"; - -test(`the default members of a new HiFiCommunicator instantiation`, () => { - let newHiFiCommunicator = new HiFiCommunicator(); - expect(newHiFiCommunicator.transmitRateLimitTimeoutMS).toBe(HiFiConstants.DEFAULT_TRANSMIT_RATE_LIMIT_TIMEOUT_MS); - newHiFiCommunicator.disconnectFromHiFiAudioAPIServer(); -}); \ No newline at end of file diff --git a/tests/unit/src/classes/HiFiMixerSession.unit.test.ts b/tests/unit/src/classes/HiFiMixerSession.unit.test.ts deleted file mode 100644 index 942f993f..00000000 --- a/tests/unit/src/classes/HiFiMixerSession.unit.test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { HiFiMixerSession } from "../../../../src/classes/HiFiMixerSession"; - -test(`brand new mixer session can't connect`, () => { - let newMixerSession = new HiFiMixerSession({}); - expect(newMixerSession.connect()).rejects.toBeDefined(); -}); \ No newline at end of file diff --git a/tests/unit/src/utilities/HiFiLogger.unit.test.ts b/tests/unit/src/utilities/HiFiLogger.unit.test.ts deleted file mode 100644 index c3113d0b..00000000 --- a/tests/unit/src/utilities/HiFiLogger.unit.test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { HiFiLogger, HiFiLogLevel } from "../../../../src/utilities/HiFiLogger"; - -test(`the default log level is Error`, () => { - expect(HiFiLogger.log('Log: If you see this, a test has failed!')).toBe(false); - expect(HiFiLogger.warn('Warn: If you see this, a test has failed!')).toBe(false); - expect(HiFiLogger.error('Error: If you see this, a test has succeeded!')).toBe(true); -}); - -test(`we won't log warnings to the console if our log level is error`, () => { - HiFiLogger.setHiFiLogLevel(HiFiLogLevel.Error); - expect(HiFiLogger.warn('If you see this, a test has failed!')).toBe(false); -}); \ No newline at end of file diff --git a/tests/unit/testUtilities/globalTeardown.js b/tests/unit/testUtilities/globalTeardown.js deleted file mode 100644 index 374d6767..00000000 --- a/tests/unit/testUtilities/globalTeardown.js +++ /dev/null @@ -1,5 +0,0 @@ -// This function is triggered once after all test suites. -// If we don't run this, some code within wrtc prevents Jest from exiting properly. -module.exports = () => { - process.exit(0) -}; \ No newline at end of file From 113937a74ba7698f610e007c9911a39e6a08bf90 Mon Sep 17 00:00:00 2001 From: Maia Hansen Date: Thu, 4 Mar 2021 18:45:40 -0800 Subject: [PATCH 2/2] Bumping to v0.4.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5f09d5b2..78701bb3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "0.4.1", + "version": "0.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ac1abf20..0746fd11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hifi-spatial-audio", - "version": "0.4.1", + "version": "0.4.2", "description": "hifi-spatial-audio allows developers to integrate High Fidelity's spatial audio technology into their JavaScript projects.", "main": "./dist/index.js", "types": "./dist/index.d.ts",