Skip to content

Commit

Permalink
Merge pull request #109 from aurelienrichard:privelte
Browse files Browse the repository at this point in the history
update vitest config
  • Loading branch information
aurelienrichard committed Apr 28, 2024
2 parents fd91395 + 67331bb commit 0a6bf07
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 27 deletions.
9 changes: 0 additions & 9 deletions apps/privelte/src/hooks.server.ts

This file was deleted.

8 changes: 4 additions & 4 deletions apps/privelte/src/routes/room/[id]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const POST: RequestHandler = async ({ request, cookies, params }) => {
.throwOnError()
} catch (e) {
console.error(e)
return error(401, 'Unauthorized.')
error(401, 'Unauthorized.')
}

const body = (await request.json()) as Pick<Payload, 'id' | 'message'>
Expand All @@ -39,7 +39,7 @@ export const POST: RequestHandler = async ({ request, cookies, params }) => {
payload = { type: 'payload', id, message, userId, username }
} catch (e) {
console.error(e)
return error(400, 'Invalid ID or message.')
error(400, 'Invalid ID or message.')
}

const channel = supabase.channel(params.id, {
Expand All @@ -54,7 +54,7 @@ export const POST: RequestHandler = async ({ request, cookies, params }) => {
})

if (response !== 'ok') {
return error(500, { message: 'Internal error.' })
error(500, { message: 'Internal error.' })
}
} finally {
await supabase.removeChannel(channel)
Expand Down Expand Up @@ -86,7 +86,7 @@ export const PATCH: RequestHandler = async ({ cookies, params }) => {
})
} catch (e) {
console.error(e)
return error(401, 'Unauthorized.')
error(401, 'Unauthorized.')
}

return new Response(null, { status: 204 })
Expand Down
8 changes: 4 additions & 4 deletions apps/privelte/src/routes/room/[id]/join/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export const actions: Actions = {
const room = await supabase.from('rooms').select('*').eq('id', params.id!).single()

if (room.error) {
return error(404, { message: 'This room does not exist.' })
error(404, { message: 'This room does not exist.' })
}

const participants = room.data.participants ?? 0

if (participants === room.data.slots) {
return error(403, { message: 'This room is full.' })
error(403, { message: 'This room is full.' })
}

const form = await request.formData()
Expand All @@ -60,9 +60,9 @@ export const actions: Actions = {
})
} catch (e) {
console.error(e)
return error(500, { message: 'Internal error.' })
error(500, { message: 'Internal error.' })
}

return redirect(303, `/room/${params.id}`)
redirect(303, `/room/${params.id}`)
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/privelte/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const config = {
typescript: {
config: (config) => ({
...config,
include: [...config.include, '../tailwind.config.ts', '../vitest-setup.ts']
include: [...config.include, '../tailwind.config.ts']
})
},
paths: {
Expand Down
8 changes: 4 additions & 4 deletions apps/privelte/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { sveltekit } from '@sveltejs/kit/vite'
import { purgeCss } from 'vite-plugin-tailwind-purgecss'
import { defineConfig, type PluginOption } from 'vite'
import { defineConfig } from 'vite'

export default defineConfig(({ mode }) => ({
plugins: [sveltekit() as PluginOption, purgeCss()],
plugins: [sveltekit(), purgeCss()],
resolve: {
conditions: mode === 'test' ? ['browser'] : []
},
test: {
include: ['src/**/*.test.ts'],
environmentMatchGlobs: [['**/[A-Z]*.test.ts', 'happy-dom']],
setupFiles: ['./vitest-setup.ts']
environmentMatchGlobs: [['**/*.svelte.test.ts', 'happy-dom']],
setupFiles: ['./src/vitest-setup.ts']
}
}))
File renamed without changes.
2 changes: 1 addition & 1 deletion apps/svelteflix/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const config = {
typescript: {
config: (config) => ({
...config,
include: [...config.include, '../tailwind.config.ts', '../vitest-setup.ts']
include: [...config.include, '../tailwind.config.ts']
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions apps/svelteflix/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { sveltekit } from '@sveltejs/kit/vite'
import { defineConfig, type PluginOption } from 'vite'
import { defineConfig } from 'vite'

export default defineConfig({
plugins: [sveltekit() as PluginOption],
plugins: [sveltekit()],
test: {
include: ['src/**/*.test.ts'],
environmentMatchGlobs: [['**/[A-Z]*.test.ts', 'happy-dom']],
setupFiles: ['./vitest-setup.ts']
environmentMatchGlobs: [['**/*.svelte.test.ts', 'happy-dom']],
setupFiles: ['./src/vitest-setup.ts']
}
})

0 comments on commit 0a6bf07

Please sign in to comment.