This repository was archived by the owner on Aug 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
tests: unit tests for route #7837
Merged
the-reality-engineer
merged 11 commits into
ir-engine:dev
from
aditya-mitra:tests/route
May 30, 2023
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ac22634
tests: unit tests for route
aditya-mitra 274cbe0
Merge branch 'dev' into tests/route
aditya-mitra 771dfb7
fix: update xrengine.config for test
aditya-mitra 0a28614
Merge branch 'dev' into tests/route
aditya-mitra 7a48399
chore: rename project as route
aditya-mitra 8dc00de
fix: params is optional in route-activate
aditya-mitra 0cd1c17
chore: use different variable for project
aditya-mitra 2f8a680
Merge branch 'dev' into tests/route
aditya-mitra 8fde8c4
fix: typescript error in route.ts
aditya-mitra 9a7eeb3
Merge branch 'dev' into tests/route
aditya-mitra 55b6a59
Merge branch 'dev' into tests/route
aditya-mitra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import appRootPath from 'app-root-path' | ||
| import assert from 'assert' | ||
| import path from 'path' | ||
| import { v4 as uuid } from 'uuid' | ||
|
|
||
| import { destroyEngine } from '@etherealengine/engine/src/ecs/classes/Engine' | ||
|
|
||
| import { Application } from '../../../declarations' | ||
| import { createFeathersExpressApp } from '../../createApp' | ||
| import { deleteFolderRecursive } from '../../util/fsHelperFunctions' | ||
|
|
||
| const params = { isInternal: true } as any | ||
|
|
||
| const cleanup = async (app: Application, projectName: string) => { | ||
| const projectDir = path.resolve(appRootPath.path, `packages/projects/projects/${projectName}/`) | ||
| deleteFolderRecursive(projectDir) | ||
| try { | ||
| await app.service('project').Model.destroy({ where: { name: projectName } }) | ||
| } catch (e) {} | ||
| } | ||
|
|
||
| describe('route.test', () => { | ||
| let app: Application | ||
| let newProject: string | ||
|
|
||
| before(async () => { | ||
| app = createFeathersExpressApp() | ||
| await app.setup() | ||
| }) | ||
|
|
||
| after(async () => { | ||
| await destroyEngine() | ||
| await cleanup(app, newProject) | ||
| }) | ||
|
|
||
| it('should find the installed project routes', async () => { | ||
| newProject = `test-project-${uuid()}` | ||
| await app.service('project').create({ name: newProject }, params) | ||
|
|
||
| const installedRoutes = await app.service('routes-installed').find() | ||
| const route = installedRoutes.data.find((route) => route.project === newProject) | ||
|
|
||
| assert.ok(route) | ||
| assert.equal(route.project, newProject) | ||
| }) | ||
|
|
||
| it('should not be activated by default (the installed project)', async () => { | ||
| const route = await app.service('route').find({ query: { project: newProject } }) | ||
| assert.equal(route.total, 0) | ||
| }) | ||
|
|
||
| it('should activate a route', async () => { | ||
| const activateResult = await app | ||
| .service('route-activate') | ||
| .create({ project: newProject, route: newProject, activate: true }, params) | ||
| const route = await app.service('route').find() | ||
|
|
||
| assert.ok(activateResult) | ||
| assert.equal(route.total, 1) | ||
| assert.equal(route.data.project, newProject) | ||
| assert.equal(route.data.route, newProject) | ||
| }) | ||
|
|
||
| it('should deactivate a route', async () => { | ||
| await app.service('route-activate').create({ project: newProject, route: newProject, activate: false }, params) | ||
|
|
||
| const route = await app.service('route').find({ query: { project: newProject } }) | ||
| assert.equal(route.total, 0) | ||
| }) | ||
| }) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.