-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-table.spec.ts
46 lines (37 loc) · 1.3 KB
/
create-table.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {DynamormException} from '../src/exceptions';
import {TestTable, db, client} from './fixtures/test-table';
jest.useFakeTimers()
describe('Create / Delete Table', () => {
describe('Dynamorm container instance', () => {
it('should create tables from container', async () => {
await expect(db.createTables).rejects.not.toThrow(DynamormException);
})
it('should delete tables from container', async () => {
await expect(db.deleteTables).rejects.not.toThrow(DynamormException);
})
})
describe('Table instance', () => {
let table;
beforeEach(() => {
table = new TestTable(client);
})
it('should create database table', async () => {
const createTable = async () => {
setTimeout(async () => await table.create(), 200)
}
expect(createTable).not.toThrow();
})
it('should create database table if not exists', async () => {
const createTable = async () => {
setTimeout(async () => await table.create('IF_NOT_EXISTS'), 200)
}
expect(createTable).not.toThrow(DynamormException);
})
it('should delete table', async () => {
const deleteTable = async () => {
setTimeout(async () => await table.delete(), 200)
}
expect(deleteTable).not.toThrow(DynamormException);
})
})
})