11'use strict' ;
22/* global describe, it, before; */
3- require ( 'co-mocha' ) ( require ( 'mocha' ) ) ;
43
54const Assert = require ( 'assert' ) ;
65const Database = require ( '../src/core' ) . Database ;
76
8- var db , collection ;
9-
107describe ( 'Database' , ( ) => {
118
12- it ( 'should connect to database' , function * ( done ) {
9+ var db , collection ;
10+
11+ it ( 'should connect to database' , function * ( ) {
1312 db = yield Database . connect ( ) ;
1413 Assert . notEqual ( db , null ) ;
15- done ( ) ;
1614 } ) ;
1715
18- it ( 'should access the collection test' , function * ( done ) {
16+ it ( 'should access the collection test' , function * ( ) {
1917 collection = db . collection ( 'test' ) ;
2018 Assert . notEqual ( collection , null ) ;
21- done ( ) ;
2219 } ) ;
2320
24- it ( 'should insert data in the collection' , function * ( done ) {
21+ it ( 'should insert data in the collection' , function * ( ) {
2522 yield collection . insert ( { name : 'Fulano' } ) ;
2623
2724 var item = yield collection . findOne ( { name : 'Fulano' } ) ;
2825 Assert . equal ( item . name , 'Fulano' ) ;
29- done ( ) ;
3026 } ) ;
3127
32- it ( 'should update Fulano in the collection' , function * ( done ) {
28+ it ( 'should update Fulano in the collection' , function * ( ) {
3329 var item = yield collection . findOne ( { name : 'Fulano' } ) ;
3430 item . name = 'Ciclano' ;
3531 yield item . save ( ) ;
3632 Assert . equal ( item . name , 'Ciclano' ) ;
37- done ( ) ;
3833 } ) ;
3934
40- it ( 'should retrieve all documents in test collection' , function * ( done ) {
35+ it ( 'should retrieve all documents in test collection' , function * ( ) {
4136 var items = yield collection . find ( { } ) ;
4237 Assert . notEqual ( items . length , 0 ) ;
43- done ( ) ;
4438 } ) ;
4539
46- it ( 'should remove all documents in test collection' , function * ( done ) {
40+ it ( 'should remove all documents in test collection' , function * ( ) {
4741 yield collection . remove ( { } ) ;
4842 var items = yield collection . find ( { } ) ;
4943 Assert . equal ( items . length , 0 ) ;
50- done ( ) ;
5144 } ) ;
5245} ) ;
0 commit comments