Skip to content

Instantly share code, notes, and snippets.

@rtgibbons rtgibbons/post_test.js
Last active Oct 1, 2015

Embed
What would you like to do?
mocha test on Keystone Model
process.env.NODE_ENV = process.env.NODE_ENV || 'test';
require('dotenv').load();
var keystone = require('keystone');
var chai = require('chai');
var dbURI = process.env.MONGO_URL
keystone.init({
'name': 'Post Model Test',
's3 config': {} //has to be set, but isn't used in our models
});
var Post = null;
keystone.import('../../models');
chai.should();
describe('Posts', function() {
beforeEach(function(done){
if (keystone.mongoose.connection.db) return done();
console.log('Connecting to ' + dbURI)
keystone.mongoose.connect(dbURI, done);
});
it('should be a connection to Mongo', function(done){
keystone.mongoose.connection.db.should.be.a('Object');
done();
});
it('should be a Mongoose Model', function(done) {
Post = keystone.list('Post');
Post.should.be.a('Object');
Post.should.have.property('model').be.a('Function');
Post.should.have.property('schema').be.a('Object');
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.