Last active
October 1, 2015 19:26
-
-
Save rtgibbons/e18d8066680a0350fe41 to your computer and use it in GitHub Desktop.
mocha test on Keystone Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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