feat: delete a custom type

This commit is contained in:
Florian Sylvain committed 2026-10-20 17:56:44 +02:00
1 parent 76e9e1220c
commit 5404291af2
25 files changed
+1768 -46

No files matched your search

+7
View File
@@ -131,6 +131,7 @@ export interface SchemaMount {
create?: (body: PostedRequest['body']) => unknown
update?: (body: PostedRequest['body'], key: string) => unknown
entries?: (key: string) => unknown
remove?: (key: string) => unknown
width?: number
content?: Responder
builtin?: Responder
@@ -142,6 +143,7 @@ let wrapper: VueWrapper | undefined
export const calls: string[] = []
export const posts: PostedRequest[] = []
export const puts: PostedRequest[] = []
export const deletes: string[] = []
export function updatedType(key: string, body: Record<string, unknown>) {
const base = customTypes.find((type) => type.key === key)!
@@ -152,6 +154,7 @@ export async function mountAt(path: string, options: SchemaMount = {}, shellOnly
calls.length = 0
posts.length = 0
puts.length = 0
deletes.length = 0
localStorage.clear()
setViewportWidth(options.width ?? DESKTOP_WIDTH)
const pinia = createPinia()
@@ -173,6 +176,10 @@ export async function mountAt(path: string, options: SchemaMount = {}, shellOnly
}
session.status = 'ready'
const request = vi.fn(async (url: string, init?: RequestInit) => {
if (init?.method === 'DELETE') {
deletes.push(url)
return (options.remove ?? (() => undefined))(url.split('/').pop()!)
}
if (init?.method === 'PUT') {
const body = JSON.parse(String(init.body)) as PostedRequest['body']
const key = url.split('/').pop()!