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

39 lines
895 B
TypeScript

import { setPrismaDataSource } from '@blitzjs/installer'
describe('setPrismaDataSource', () => {
const subject = (source: string) =>
setPrismaDataSource(source, {
type: 'datasource',
name: 'db',
assignments: [
{ type: 'assignment', key: 'provider', value: '"postgresql"' },
{
type: 'assignment',
key: 'url',
value: { type: 'function', name: 'env', params: ['"DATABASE_URL"'] },
},
],
})
it('sets datasource', async () => {
const source = `
// comment up here
datasource db {
provider = "sqlite"
url = "file:./db.sqlite"
}
// comment down here`.trim()
expect(await subject(source)).toMatchSnapshot()
})
it('adds datasource if missing', async () => {
const source = `
// wow there is no datasource here
`.trim()
expect(await subject(source)).toMatchSnapshot()
})
})