From a555e2cc29927211f251d0839a0da28dce1eca28 Mon Sep 17 00:00:00 2001 From: Aditya Mitra <55396651+aditya-mitra@users.noreply.github.com> Date: Fri, 29 Dec 2023 06:47:24 +0530 Subject: [PATCH] added tests for portal service (#9448) * added tests for portal service * added license comment --- .../src/projects/portal/portal.test.ts | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 packages/server-core/src/projects/portal/portal.test.ts diff --git a/packages/server-core/src/projects/portal/portal.test.ts b/packages/server-core/src/projects/portal/portal.test.ts new file mode 100644 index 0000000000..d0c18b1a5b --- /dev/null +++ b/packages/server-core/src/projects/portal/portal.test.ts @@ -0,0 +1,63 @@ +/* +CPAL-1.0 License + +The contents of this file are subject to the Common Public Attribution License +Version 1.0. (the "License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at +https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. +The License is based on the Mozilla Public License Version 1.1, but Sections 14 +and 15 have been added to cover use of software over a computer network and +provide for limited attribution for the Original Developer. In addition, +Exhibit A has been modified to be consistent with Exhibit B. + +Software distributed under the License is distributed on an "AS IS" basis, +WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the +specific language governing rights and limitations under the License. + +The Original Code is Ethereal Engine. + +The Original Developer is the Initial Developer. The Initial Developer of the +Original Code is the Ethereal Engine team. + +All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 +Ethereal Engine. All Rights Reserved. +*/ + +import { destroyEngine } from '@etherealengine/engine/src/ecs/classes/Engine' +import { PortalType, portalPath } from '@etherealengine/engine/src/schemas/projects/portal.schema' +import assert from 'assert' +import { Application } from '../../../declarations' +import { createFeathersKoaApp } from '../../createApp' + +describe('portal.test', () => { + let app: Application + + before(async () => { + app = createFeathersKoaApp() + await app.setup() + }) + + after(async () => { + await destroyEngine() + }) + + let apartmentPortal: PortalType + + it('should find the portals', async () => { + const foundPortals = (await app.service(portalPath).find()) as { data: PortalType[]; total: number } + + apartmentPortal = foundPortals.data.find((portal) => portal.sceneName === 'apartment')! + + assert.ok(foundPortals.total > 0) + assert.ok(apartmentPortal) + }) + + it('should get the portal', async () => { + const foundApartmentPortal = await app + .service(portalPath) + .get(apartmentPortal.portalEntityId, { query: { locationName: 'apartment' } }) + assert.equal(foundApartmentPortal.portalEntityId, apartmentPortal.portalEntityId) + assert.equal(foundApartmentPortal.previewImageURL, apartmentPortal.previewImageURL) + assert.equal(foundApartmentPortal.sceneName, apartmentPortal.sceneName) + }) +})