remove unfinished test config changes

This commit is contained in:
Dan Ribbens
2019-10-29 10:18:06 -04:00
parent c2ce6a4f38
commit 4b3412fdfb
4 changed files with 1 additions and 52 deletions

View File

@@ -87,8 +87,7 @@ class Payload {
.forEach(collection => {
const config = collection.config;
const model = collection.model;
// console.log(config.slug, model.schema.tree);
// console.log(model.schema.tree.flexible && model.schema.tree.flexible[0].discriminators || 'na');
// register passport with model
if (config.auth) {
passport.use(model.createStrategy());

View File

@@ -8,5 +8,4 @@ module.exports = {
'^.+\\.(j|t)s$': 'babel-jest'
},
testEnvironment: 'node',
setupFilesAfterEnv: ['./jest.setup.js']
};

View File

@@ -1,33 +0,0 @@
const mongoose = require('mongoose');
const databaseName = 'test';
async function dropAllCollections () {
const collections = Object.keys(mongoose.connection.collections);
for (const collectionName of collections) {
const collection = mongoose.connection.collections[collectionName];
try {
await collection.drop();
} catch (error) {
// This error happens when you try to drop a collection that's already dropped. Happens infrequently.
// Safe to ignore.
if (error.message === 'ns not found') return;
// This error happens when you use it.todo.
// Safe to ignore.
if (error.message.includes('a background operation is currently running')) return;
console.log(error.message);
}
}
}
beforeAll(async () => {
const url = `mongodb://localhost/${databaseName}`;
await mongoose.connect(url, { useNewUrlParser: true, useUnifiedTopology: true });
});
afterAll(async () => {
await dropAllCollections();
// Closes the Mongoose connection
await mongoose.connection.close();
});

View File

@@ -23,20 +23,4 @@ describe('schemaLoader', () => {
expect(schemaLoader.blockSchema).not.toBeNull();
expect(schemaLoader.contentBlocks).not.toBeNull();
});
xit('insert content block', async () => {
const Quote = schemaLoader.contentBlocks.quote.model;
await new Quote({
author: 'Bob',
quote: 'Hi there',
color: '#ddd',
}).save(() => {
// not working without a callback? I don't understand
});
const quote = await Quote.findOne({author: 'Bob'});
expect(quote.author).toEqual('Bob');
});
});