'use strict';

const mongo = require('../lib/db');

const User = require('../models/User');
const Checkin = require('../models/Checkin');

const users = require('./fixtures/users');
const checkins = require('./fixtures/checkins');

// mongodb connect
before(function before(done) {
  this.timeout(10000);

  if (mongo.connection._hasOpened) {
    process.nextTick(done);
  } else {
    mongo.connection.once('open', done);
  }
});

// mongodb clean
beforeEach(() => mongo.connection.db.dropDatabase());

// mongodb insert
beforeEach(() => Promise.all([
  User.collection.collection.insert(users),
  Checkin.collection.collection.insert(checkins),
]));

@@ -421,24 +421,91 @@
 );%0A  %7D%0A%7D);%0A%0A
+after(() =%3E %7B%0A  mongo.models = %7B%7D;%0A  mongo.modelSchemas = %7B%7D;%0A%7D);%0A%0A
 // mongodb c

clear mongoose model after testing