本文整理匯總了TypeScript中prisma-datamodel.SdlExpect.error方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript SdlExpect.error方法的具體用法?TypeScript SdlExpect.error怎麽用?TypeScript SdlExpect.error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類prisma-datamodel.SdlExpect
的用法示例。
在下文中一共展示了SdlExpect.error方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('Should create types for arrays correctly', () => {
const arrays = {
_id: 'this-is-so-unique',
floatArray: [0, 1.2, 5],
stringArray: ['hello'],
mixedArray: [0, 'hello', false],
nestedArray: [[0, 1], [2, 3]]
}
const merger = new ModelMerger('arrays', false, new MockDocumentDataSource({}))
merger.analyze(arrays)
const { type } = merger.getType()
expect(type.name).toBe('arrays')
SdlExpect.field(type, '_id', true, false, TypeIdentifiers.string, true)
SdlExpect.field(type, 'stringArray', false, true, TypeIdentifiers.string)
SdlExpect.field(type, 'floatArray', false, true, TypeIdentifiers.float)
const mixedField = SdlExpect.field(type, 'mixedArray', false, true, ModelSampler.ErrorType)
SdlExpect.error(mixedField)
const nestedField = SdlExpect.field(type, 'nestedArray', false, true, ModelSampler.ErrorType)
SdlExpect.error(nestedField)
})
示例2: it
it('Should bail on type conflict.', () => {
const user1 = {
lastName: 'Test-1',
shippingAddress: {
country: 'Germany'
}
}
const user2 = {
lastName: [false],
firstName: 'Test-2',
shippingAddress: {
country: 'Germany',
street: 8
}
}
const user3 = {
firstName: 'Test-2',
shippingAddress: {
street: 'Teststreet',
houseNumber: 4
}
}
const merger = new ModelMerger('User', false, new MockDocumentDataSource({}))
merger.analyze(user1)
merger.analyze(user2)
merger.analyze(user3)
const { type, embedded } = merger.getType()
const embeddedType = SdlExpect.type(embedded, 'UserShippingAddress', false, true)
expect(type.fields).toHaveLength(3)
const conflictingEmbeddedField = SdlExpect.field(embeddedType, 'street', false, false, ModelSampler.ErrorType)
SdlExpect.error(conflictingEmbeddedField)
const conflictingField = SdlExpect.field(type, 'lastName', false, false, ModelSampler.ErrorType)
SdlExpect.error(conflictingField)
})