forked from Automattic/mongoose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.type.test.js
31 lines (26 loc) · 1.14 KB
/
schema.type.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* Module dependencies.
*/
var mongoose = require('./common').mongoose
, assert = require('assert')
, Schema = mongoose.Schema
describe('schematype', function(){
it('honors the selected option', function(done){
var s = new Schema({ thought: { type: String, select: false }});
assert.equal(false, s.path('thought').selected);
var a = new Schema({ thought: { type: String, select: true }});
assert.equal(true, a.path('thought').selected);
done();
})
it('properly handles specifying index in combination with unique or sparse', function(done){
var s = new Schema({ name: { type: String, index: true, unique: true }});
assert.deepEqual(s.path('name')._index, { unique: true });
var s = new Schema({ name: { type: String, unique: true, index: true }});
assert.deepEqual(s.path('name')._index, { unique: true });
var s = new Schema({ name: { type: String, index: true, sparse: true }});
assert.deepEqual(s.path('name')._index, { sparse: true });
var s = new Schema({ name: { type: String, sparse: true, index: true }});
assert.deepEqual(s.path('name')._index, { sparse: true });
done();
})
})