1
0
mirror of synced 2025-12-19 18:11:23 -05:00
Files
blitz/nextjs/packages/installer/test/transforms/prisma/add-prisma-model-attribute.test.ts
2021-12-10 13:26:54 +01:00

44 lines
942 B
TypeScript

import { addPrismaModelAttribute } from '@blitzjs/installer'
describe('addPrismaModelAttribute', () => {
const subject = (source: string) =>
addPrismaModelAttribute(source, 'Project', {
type: 'attribute',
kind: 'model',
name: 'index',
args: [
{
type: 'attributeArgument',
value: {
type: 'array',
args: ['name'],
},
},
],
})
it('creates index', async () => {
const source = `
datasource db {
provider = "sqlite"
url = "file:./db.sqlite"
}
model Project {
id Int @id @default(autoincrement())
name String @unique
}`.trim()
expect(await subject(source)).toMatchSnapshot()
})
it('skips if model is missing', async () => {
const source = `
datasource db {
provider = "sqlite"
url = "file:./db.sqlite"
}`.trim()
expect(await subject(source)).toMatchSnapshot()
})
})