Skip to content

Commit f3932dc

Browse files
Update tests
1 parent aadf8c8 commit f3932dc

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

test/src/index.spec.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const _ = require('lodash');
44
import '../setup';
55
import DynamoAdapter from '../../src/index.js';
6+
import { helpers } from '../../src/helpers.js';
67
import { dbData } from './test-data';
78
import { model, adapter, use } from 'modli';
89
let dynamoConfig = {
@@ -505,6 +506,17 @@ describe('standard model', () => {
505506
});
506507

507508
describe('autocreate coverage', () => {
509+
before((done) => {
510+
// Make sure table exists
511+
helpers.checkCreateTable(numeric, false);
512+
// Make sure table exists before trying to delete it, and then auto creating it again
513+
helpers.checkCreateTable(standard, false).then(() => {
514+
standard.deleteTable({TableName: dbData.testModel.tableName}).then(() => {
515+
helpers.checkCreateTable(standard, false);
516+
done();
517+
});
518+
});
519+
});
508520
it('Fails to create on non-existent table', (done) => {
509521
numeric.deleteTable({TableName: dbData.testNumericModel.tableName}).then(() => {
510522
numeric.create(dbData.numericAccount.Item, '1').then((data) => {
@@ -515,20 +527,13 @@ describe('standard model', () => {
515527
});
516528
});
517529

518-
it('Successfully creates first account on tables from post', (done) => {
530+
it('Successfully creates account on autocreated table', (done) => {
519531
standard.create(dbData.testAccount1.Item, '1').then((data) => {
520532
expect(data).to.be.an.object;
521533
done();
522534
});
523535
});
524536

525-
it('Successfully creates second account on autocreated table', (done) => {
526-
standard.create(dbData.testAccount2.Item, '1').then((data) => {
527-
expect(data).to.be.an.object;
528-
done();
529-
});
530-
});
531-
532537
it('removes autocreated test table', (done) => {
533538
standard.deleteTable({TableName: dbData.testModel.tableName}).then((data) => {
534539
expect(data).to.be.an.object;

0 commit comments

Comments
 (0)