-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: cover transformDMMF with a test
- Loading branch information
Victor Korzunin
committed
Sep 14, 2021
1 parent
77afaa1
commit 74a9b25
Showing
3 changed files
with
79 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { getDMMF } from '@prisma/sdk'; | ||
import { PrismaTypeToSequelizeType } from '../../src/generator/properties'; | ||
|
||
import { transformDMMF } from '../../src/generator/transformDMMF'; | ||
|
||
describe('given transformDMMF,', () => { | ||
it('should transform properly.', async () => { | ||
expect.assertions(1); | ||
|
||
const datamodel = ` | ||
model User { | ||
id String @id | ||
} | ||
`; | ||
const expectedProperties = { | ||
models: [ | ||
{ | ||
modelName: 'User', | ||
dbName: null, | ||
scalarFields: [ | ||
{ | ||
fieldName: 'id', | ||
allowNull: false, | ||
hasDefaultValue: false, | ||
isAutoincrement: false, | ||
isId: true, | ||
isList: false, | ||
isUnique: false, | ||
type: PrismaTypeToSequelizeType.String, | ||
}, | ||
], | ||
belongsToFields: [], | ||
hasManyFields: [], | ||
hasOneFields: [], | ||
hasCreatedAt: false, | ||
hasUpdatedAt: false, | ||
hasDeletedAt: false, | ||
}, | ||
], | ||
}; | ||
|
||
const dmmf = await getDMMF({ datamodel }); | ||
const result = transformDMMF(dmmf); | ||
|
||
expect(result).toStrictEqual(expectedProperties); | ||
}); | ||
}); |