@@ -57,6 +57,32 @@ module.exports = describe("Task", function(){
57
57
} ) ;
58
58
} ) ;
59
59
60
+ describe ( "#save nested object" , function ( ) {
61
+ it ( "should save successfully with model" , function ( ) {
62
+ var nested = new TestMdlA ( { name : "Nested User 1" , info : { foo : 'bar' , some : 'string' } } ) ;
63
+
64
+ return task . save ( TestMdlA , nested ) . run ( ) ;
65
+ } ) ;
66
+
67
+ it ( "should have Nested User in " + TEST_COLLECTION_A , function ( ) {
68
+ return expect ( TestMdlA . find ( { name : "Nested User 1" , 'info.foo' : 'bar' } ) . exec ( ) ) . to . eventually . have . length ( 1 ) ;
69
+ } ) ;
70
+
71
+ it ( "should save successfully with only doc" , function ( ) {
72
+ var nested = new TestMdlA ( { name : "Nested User 2" , info : { foo : 'bar' , some : 'string' } } ) ;
73
+
74
+ return task . save ( nested ) . run ( ) ;
75
+ } ) ;
76
+
77
+ it ( "should have Nested User in " + TEST_COLLECTION_A , function ( ) {
78
+ return expect ( TestMdlA . find ( { name : "Nested User 2" , 'info.foo' : 'bar' } ) . exec ( ) ) . to . eventually . have . length ( 1 ) ;
79
+ } ) ;
80
+
81
+ it ( TEST_COLLECTION_A + " should have length 4" , function ( ) {
82
+ return expect ( TestMdlA . find ( ) . exec ( ) ) . to . eventually . have . length ( 4 ) ;
83
+ } ) ;
84
+ } ) ;
85
+
60
86
describe ( "#update" , function ( ) {
61
87
it ( "should update successfully" , function ( ) {
62
88
return TestMdlB . findOne ( { name : "Brian Griffin" } )
@@ -85,15 +111,33 @@ module.exports = describe("Task", function(){
85
111
return expect ( TestMdlB . find ( { name : "T-REX" } ) . exec ( ) ) . to . eventually . have . length ( 1 ) ;
86
112
} ) ;
87
113
88
- it ( TEST_COLLECTION_A + " should have length 2 " , function ( ) {
89
- return expect ( TestMdlA . find ( ) . exec ( ) ) . to . eventually . have . length ( 2 ) ;
114
+ it ( TEST_COLLECTION_A + " should have length 4 " , function ( ) {
115
+ return expect ( TestMdlA . find ( ) . exec ( ) ) . to . eventually . have . length ( 4 ) ;
90
116
} ) ;
91
117
92
118
it ( TEST_COLLECTION_B + " should have length 2" , function ( ) {
93
119
return expect ( TestMdlB . find ( ) . exec ( ) ) . to . eventually . have . length ( 2 ) ;
94
120
} ) ;
95
121
} ) ;
96
122
123
+ describe ( "#update $ token" , function ( ) {
124
+ it ( "should update successfully with $gte" , function ( ) {
125
+ return task . update ( TestMdlB , { name : "Yo momma" , age : { $gte : 38 } } , { $inc : { age : 20 } } ) . run ( ) ;
126
+ } ) ;
127
+
128
+ it ( "should have Yo momma in " + TEST_COLLECTION_B + " with age 58" , function ( ) {
129
+ return expect ( TestMdlB . find ( { name : "Yo momma" , age : 58 } ) . exec ( ) ) . to . eventually . have . length ( 1 ) ;
130
+ } ) ;
131
+
132
+ it ( "should update successfully with $inc" , function ( ) {
133
+ return task . update ( TestMdlB , { name : "Yo momma" , age : { $in : [ 58 , 59 ] } } , { $inc : { age : - 20 } } ) . run ( ) ;
134
+ } ) ;
135
+
136
+ it ( "should have Yo momma in " + TEST_COLLECTION_B + " with age 38" , function ( ) {
137
+ return expect ( TestMdlB . find ( { name : "Yo momma" , age : 38 } ) . exec ( ) ) . to . eventually . have . length ( 1 ) ;
138
+ } ) ;
139
+ } ) ;
140
+
97
141
describe ( "#remove" , function ( ) {
98
142
it ( "should remove successfully" , function ( ) {
99
143
return TestMdlB . findOne ( { name : "Yo momma" } )
@@ -122,8 +166,8 @@ module.exports = describe("Task", function(){
122
166
return expect ( TestMdlB . find ( { name : "T-REX" } ) . exec ( ) ) . to . eventually . have . length ( 1 ) ;
123
167
} ) ;
124
168
125
- it ( TEST_COLLECTION_A + " should have length 1 " , function ( ) {
126
- return expect ( TestMdlA . find ( ) . exec ( ) ) . to . eventually . have . length ( 1 ) ;
169
+ it ( TEST_COLLECTION_A + " should have length 3 " , function ( ) {
170
+ return expect ( TestMdlA . find ( ) . exec ( ) ) . to . eventually . have . length ( 3 ) ;
127
171
} ) ;
128
172
129
173
it ( TEST_COLLECTION_B + " should have length 1" , function ( ) {
@@ -162,12 +206,12 @@ module.exports = describe("Task", function(){
162
206
return expect ( TestMdlB . find ( { name : "Brian Griffin" } ) . exec ( ) ) . to . eventually . have . length ( 1 ) ;
163
207
} ) ;
164
208
165
- it ( TEST_COLLECTION_A + " should have length 2 " , function ( ) {
166
- return expect ( TestMdlA . find ( ) . exec ( ) ) . to . eventually . have . length ( 2 ) ;
209
+ it ( TEST_COLLECTION_A + " should have length 4 " , function ( ) {
210
+ return expect ( TestMdlA . find ( ) . exec ( ) ) . to . eventually . have . length ( 4 ) ;
167
211
} ) ;
168
212
169
213
it ( TEST_COLLECTION_B + " should have length 2" , function ( ) {
170
214
return expect ( TestMdlB . find ( ) . exec ( ) ) . to . eventually . have . length ( 2 ) ;
171
215
} ) ;
172
216
} ) ;
173
- } ) ;
217
+ } ) ;
0 commit comments