mirror of
https://github.com/coder/coder.git
synced 2026-10-24 01:26:25 +08:00
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:
@@ -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`, {
|
||||
|
||||
Reference in New Issue
Block a user