dyngoose
Version:
Elegant DynamoDB object modeling for Typescript
40 lines (31 loc) • 961 B
text/typescript
import { expect } from 'chai'
import * as Dyngoose from '.'
.$Table({
name: `missing-table-${Math.random()}`,
backup: false,
})
export class MissingTable extends Dyngoose.Table {
.$PrimaryKey('id', 'title')
public static readonly primaryKey: Dyngoose.Query.PrimaryKey<MissingTable, number, string>
.Attribute.Number({ default: 1 })
public id: number
.Attribute.String()
public title: string
}
describe('DyngooseError', () => {
it('should throw "Cannot do operations on a non-existent table"', async () => {
const record = MissingTable.new({
id: 1,
title: 'test',
})
let error: Error | undefined
try {
await record.save()
} catch (ex) {
error = ex
}
expect(error).to.be.instanceOf(Error)
.with.property('name', 'ResourceNotFoundException')
expect(error).to.have.property('message', 'Cannot do operations on a non-existent table')
})
})