feat(api): seed reference activities and enable CORS for the worker SPA
This commit is contained in:
34
apps/api/test/seed.test.ts
Normal file
34
apps/api/test/seed.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { inArray, eq } from 'drizzle-orm';
|
||||
import { seed } from '../src/db/seed';
|
||||
import { db } from '../src/db/client';
|
||||
import { activities } from '../src/db/schema';
|
||||
|
||||
const SEED_NAMES = ['Leerrand', 'Frezen', 'Slijpen', 'Bekleden', 'Afwerken', 'Printen'];
|
||||
|
||||
describe('seed', () => {
|
||||
it('seeds the reference activities idempotently', async () => {
|
||||
await seed();
|
||||
const first = await db
|
||||
.select()
|
||||
.from(activities)
|
||||
.where(inArray(activities.name, SEED_NAMES));
|
||||
const countFirst = first.length;
|
||||
|
||||
await seed();
|
||||
const second = await db
|
||||
.select()
|
||||
.from(activities)
|
||||
.where(inArray(activities.name, SEED_NAMES));
|
||||
|
||||
expect(second.length).toBe(countFirst);
|
||||
expect(countFirst).toBe(SEED_NAMES.length);
|
||||
|
||||
const printen = await db
|
||||
.select()
|
||||
.from(activities)
|
||||
.where(eq(activities.name, 'Printen'));
|
||||
expect(printen).toHaveLength(1);
|
||||
expect(printen[0]?.insoleTypes).toEqual(['3D']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user