diff --git a/tests/coreunit.test.ts b/tests/coreunit.test.ts index a7d868af..5031fc88 100644 --- a/tests/coreunit.test.ts +++ b/tests/coreunit.test.ts @@ -1,14 +1,14 @@ import { test, expect } from 'vitest'; import builder from 'gql-query-builder'; +import { CoreUnit } from '@prisma/client'; import { cleanDatabase as cleanDatabaseBeforeAfterEachTest } from './helpers/database'; import { executeGraphQlQuery } from './helpers/server'; import { getPrisma } from '../src/database'; -import { CoreUnit } from '@prisma/client'; -cleanDatabaseBeforeAfterEachTest() +cleanDatabaseBeforeAfterEachTest(); test('Core Unit: get all', async () => { - const prisma = getPrisma() + const prisma = getPrisma(); await prisma.coreUnit.create({ data: { code: 'asdf', @@ -17,22 +17,22 @@ test('Core Unit: get all', async () => { imageSource: '', descriptionSentence: '', descriptionParagraph: '', - descriptionParagraphImageSource: '' - } - }) + descriptionParagraphImageSource: '', + }, + }); const query = builder.query({ operation: 'coreUnits', - fields: ['code', 'shortCode', 'name'] - }) - const response = await executeGraphQlQuery(query) as {coreUnits: CoreUnit[]} - expect(response.coreUnits).toHaveLength(1) - expect(response.coreUnits[0].code).toBe('asdf') - expect(response.coreUnits[0].shortCode).toBe('a') - expect(response.coreUnits[0].name).toBe('name') -}) + fields: ['code', 'shortCode', 'name'], + }); + const response = await executeGraphQlQuery(query) as { coreUnits: CoreUnit[] }; + expect(response.coreUnits).toHaveLength(1); + expect(response.coreUnits[0].code).toBe('asdf'); + expect(response.coreUnits[0].shortCode).toBe('a'); + expect(response.coreUnits[0].name).toBe('name'); +}); test('Core Unit: get by id', async () => { - const prisma = getPrisma() + const prisma = getPrisma(); const created = await prisma.coreUnit.create({ data: { code: 'asdf', @@ -41,16 +41,16 @@ test('Core Unit: get by id', async () => { imageSource: '', descriptionSentence: '', descriptionParagraph: '', - descriptionParagraphImageSource: '' - } - }) + descriptionParagraphImageSource: '', + }, + }); const query = builder.query({ operation: 'coreUnit', variables: { - id: created.id + id: created.id, }, - fields: ['id'] - }) - const response = await executeGraphQlQuery(query) as {coreUnit: CoreUnit} - expect(response.coreUnit.id).toBe(created.id) -}) + fields: ['id'], + }); + const response = await executeGraphQlQuery(query) as { coreUnit: CoreUnit }; + expect(response.coreUnit.id).toBe(created.id); +});