Expose DatabaseAdapter to simplify application tests (#1121)
* Move helper.clearData to DatabaseAdapter. Expose DatabaseAdapter in index * fix indentation * Export DatabaseAdapter in index.js * Rename clearData to destroyAllDataPermanently. Only export destroyAllDataPermanently from DatabaseAdapter. Update helper * Expose wrapped TestUtils from index.js. TestUtils exposed select functions from other modules, only in test environment
This commit is contained in:
@@ -8,6 +8,7 @@ var express = require('express');
|
||||
var facebook = require('../src/authDataManager/facebook');
|
||||
var ParseServer = require('../src/index').ParseServer;
|
||||
var path = require('path');
|
||||
var TestUtils = require('../src/index').TestUtils;
|
||||
|
||||
var databaseURI = process.env.DATABASE_URI;
|
||||
var cloudMain = process.env.CLOUD_CODE_MAIN || './spec/cloud/main.js';
|
||||
@@ -88,7 +89,7 @@ beforeEach(function(done) {
|
||||
|
||||
afterEach(function(done) {
|
||||
Parse.User.logOut().then(() => {
|
||||
return clearData();
|
||||
return TestUtils.destroyAllDataPermanently();
|
||||
}).then(() => {
|
||||
done();
|
||||
}, (error) => {
|
||||
@@ -232,14 +233,6 @@ function mockFacebook() {
|
||||
return facebook;
|
||||
}
|
||||
|
||||
function clearData() {
|
||||
var promises = [];
|
||||
for (var conn in DatabaseAdapter.dbConnections) {
|
||||
promises.push(DatabaseAdapter.dbConnections[conn].deleteEverything());
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
// This is polluting, but, it makes it way easier to directly port old tests.
|
||||
global.Parse = Parse;
|
||||
global.TestObject = TestObject;
|
||||
|
||||
Reference in New Issue
Block a user