@@ -9,11 +9,7 @@ var chai = require('chai'),
99describe ( 'Basic => ' , function ( ) {
1010
1111 before ( function connection ( done ) {
12- mongoose . connection . on ( 'open' , function ( ) {
13- mongoose . connection . db . dropDatabase ( function ( err ) {
14- done ( err ) ;
15- } ) ;
16- } ) ;
12+ mongoose . connection . on ( 'open' , done ) ;
1713 mongoose . connection . on ( 'error' , done ) ;
1814 mongoose . connect ( 'mongodb://127.0.0.1/mongoose-sequence-testing' ) ;
1915 } ) ;
@@ -200,53 +196,53 @@ describe('Basic => ', function() {
200196 before ( function ( done ) {
201197 var ManualSchema = new Schema ( {
202198 name : String ,
203- like : Number
199+ membercount : Number
204200 } ) ;
205- ManualSchema . plugin ( AutoIncrement , { inc_field : 'like ' , disable_hooks : true } ) ;
201+ ManualSchema . plugin ( AutoIncrement , { inc_field : 'membercount ' , disable_hooks : true } ) ;
206202 this . Manual = mongoose . model ( 'Manual' , ManualSchema ) ;
207- var t = new this . Manual ( { } ) ;
208- t . save ( done ) ;
203+ this . Manual . create ( [ { name : 't1' } , { name : 't2' } ] , done ) ;
204+
209205 } ) ;
210206
211207 it ( 'is not incremented on save' , function ( done ) {
212208 var t = new this . Manual ( { } ) ;
213209 t . save ( function ( err ) {
214210 if ( err ) return done ( err ) ;
215- assert . notEqual ( t . like , 1 ) ;
211+ assert . notEqual ( t . membercount , 1 ) ;
216212 done ( ) ;
217213 } ) ;
218214 } ) ;
219215
220216 it ( 'is incremented manually' , function ( done ) {
221- this . Manual . findOne ( { } , function ( err , entity ) {
217+ this . Manual . findOne ( { name : 't1' } , function ( err , entity ) {
222218 if ( err ) return done ( err ) ;
223- entity . setNext ( 'like ' , function ( err , entity ) {
219+ entity . setNext ( 'membercount ' , function ( err , entity ) {
224220 if ( err ) return done ( err ) ;
225- assert . deepEqual ( entity . like , 1 ) ;
221+ assert . deepEqual ( entity . membercount , 1 ) ;
226222 done ( ) ;
227223 } ) ;
228224 } ) ;
229225 } ) ;
230226
231227 it ( 'is incremented manually and the value is already saved' , function ( done ) {
232228 var Manual = this . Manual ;
233- Manual . findOne ( { } , function ( err , entity ) {
229+ Manual . findOne ( { name : 't2' } , function ( err , entity ) {
234230 if ( err ) return done ( err ) ;
235- entity . setNext ( 'like ' , function ( err , entity ) {
231+ entity . setNext ( 'membercount ' , function ( err , entity ) {
236232 if ( err ) return done ( err ) ;
237- Manual . findOne ( { } , function ( err , entity ) {
233+ Manual . findOne ( { name : 't2' } , function ( err , entity ) {
238234 if ( err ) return done ( err ) ;
239- assert . deepEqual ( entity . like , 2 ) ;
235+ assert . deepEqual ( entity . membercount , 2 ) ;
240236 done ( ) ;
241237 } ) ;
242238 } ) ;
243239 } ) ;
244240 } ) ;
245241
246242 it ( 'is not incremented manually with a wrong sequence id' , function ( done ) {
247- this . Manual . findOne ( { } , function ( err , entity ) {
243+ this . Manual . findOne ( { name : 't1' } , function ( err , entity ) {
248244 if ( err ) return done ( err ) ;
249- entity . setNext ( 'likelol ' , function ( err , entity ) {
245+ entity . setNext ( 'membercountlol ' , function ( err , entity ) {
250246 assert . isNotNull ( err ) ;
251247 done ( ) ;
252248 } ) ;
0 commit comments