chore(site): Add unit tests, mocks (#514)

* Extract and unit test redirect functions

* Move router to make app more testable

* Make mock entities more consistent

* Use labels instead of placeholders

* Fill out handlers

* Lint

* Reorganize App

* Make mock entities reference each other

* Add describes in tests

* Clean up api and mocks
This commit is contained in:
Presley Pizzo
2022-03-23 10:09:43 -04:00
committed by GitHub
parent 3bf5ceb600
commit f2ac81cc2e
10 changed files with 167 additions and 124 deletions
-20
View File
@@ -17,26 +17,6 @@ export const provisioners: Types.Provisioner[] = [
},
]
export namespace Project {
export const create = async (request: Types.CreateProjectRequest): Promise<Types.Project> => {
const response = await fetch(`/api/v2/projects/${request.organizationId}/`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(request),
})
const body = await response.json()
await mutate("/api/v2/projects")
if (!response.ok) {
throw new Error(body.message)
}
return body
}
}
export namespace Workspace {
export const create = async (request: Types.CreateWorkspaceRequest): Promise<Types.Workspace> => {
const response = await fetch(`/api/v2/users/me/workspaces`, {