-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability to define Joi.object() in schemas
- Loading branch information
1 parent
f4ed4e5
commit 0632575
Showing
2 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict' | ||
|
||
// dependencies | ||
const Joi = require('joi') | ||
const Mongoose = require('mongoose') | ||
|
||
const config = require('./config') | ||
|
||
|
||
// module under test | ||
const converters = require('../lib/adapters/mongodb/converters')() | ||
|
||
|
||
describe('Unit tests for converters module', function () { | ||
let db | ||
|
||
before(function () { | ||
return new Promise((resolve, reject) => { | ||
Mongoose.connect(config.mongodbUrl) | ||
|
||
db = Mongoose.connection | ||
db.on('error', reject) | ||
db.on('open', resolve) | ||
}) | ||
}) | ||
|
||
after(function () { | ||
return db && db.close() | ||
}) | ||
|
||
describe('funciton toMongooseModel', function () { | ||
|
||
it('should exist as a funciton', function () { | ||
expect(converters.toMongooseModel).to.be.a.Function | ||
}) | ||
|
||
it('should not fail when Joi.object() types are used in a schema', function () { | ||
const hhSchema = { | ||
type: 'testObject', | ||
attributes: { | ||
anObject: Joi.object() | ||
} | ||
} | ||
expect(converters.toMongooseModel(db, hhSchema)).to.be.a.Function | ||
}) | ||
}) | ||
}) |