3
3
const _ = require ( 'lodash' ) ;
4
4
import '../setup' ;
5
5
import DynamoAdapter from '../../src/index.js' ;
6
+ import { helpers } from '../../src/helpers.js' ;
6
7
import { dbData } from './test-data' ;
7
8
import { model , adapter , use } from 'modli' ;
8
9
let dynamoConfig = {
@@ -505,6 +506,17 @@ describe('standard model', () => {
505
506
} ) ;
506
507
507
508
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
+ } ) ;
508
520
it ( 'Fails to create on non-existent table' , ( done ) => {
509
521
numeric . deleteTable ( { TableName : dbData . testNumericModel . tableName } ) . then ( ( ) => {
510
522
numeric . create ( dbData . numericAccount . Item , '1' ) . then ( ( data ) => {
@@ -515,20 +527,13 @@ describe('standard model', () => {
515
527
} ) ;
516
528
} ) ;
517
529
518
- it ( 'Successfully creates first account on tables from post ' , ( done ) => {
530
+ it ( 'Successfully creates account on autocreated table ' , ( done ) => {
519
531
standard . create ( dbData . testAccount1 . Item , '1' ) . then ( ( data ) => {
520
532
expect ( data ) . to . be . an . object ;
521
533
done ( ) ;
522
534
} ) ;
523
535
} ) ;
524
536
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
-
532
537
it ( 'removes autocreated test table' , ( done ) => {
533
538
standard . deleteTable ( { TableName : dbData . testModel . tableName } ) . then ( ( data ) => {
534
539
expect ( data ) . to . be . an . object ;
0 commit comments