'use strict';
const Mongoose = require('mongoose');


// Specify native ECMAScript2015 Promise object as default Promise library for Mongoose
//  to use. This assignment addresses the Mongoose mpromise library deprecation warning.
Mongoose.Promise = global.Promise || Promise;

// Only ever executed once for entire test suite:
before(done => {
  Mongoose.connect('mongodb://localhost:27017/events_test');
  Mongoose
    .connection
    .on('open', () => {
      console.log('MongoDB connection for testing established.');
      done();
    })
    .on('error', (err) => {
      console.error.call(console, `Connection Error:\t${err}`);
    });
});

// Drop existing database for each (re-)run of tests:
beforeEach((done) => {
  const { EventData } = Mongoose.connection.collections;
  EventData
    .drop()
    .then(() => done())
    .catch(() => done());
});

@@ -738,16 +738,29 @@
 ventData
+, EventPhotos
  %7D = Mon
@@ -796,20 +796,16 @@
 %0A  Event
-Data
 %0A    .dr
@@ -807,16 +807,66 @@
   .drop(
+() =%3E %7B%0A      EventPhoto.drop(() =%3E done());%0A    %7D
 )%0A    .t

test (DB): Drop newly added collections on test start