@@ -25,16 +25,20 @@ describe('Model finders', function() {
2525 } ) ;
2626 } ) ;
2727
28- //it('returns a promise that resolves the correct instance', function() {
29- //return expect(resultData(Person.find(1))).to.eventually
30- //.be.instanceof(Person).and
31- //.have.property('id', '1');
32- //});
28+ it ( 'returns a promise that resolves the correct instance' , function ( done ) {
29+ resultData ( Person . find ( 1 ) ) . then ( ( data ) => {
30+ expect ( data ) . to . be . instanceof ( Person ) . and
31+ . have . property ( 'id' , '1' ) ;
32+ done ( ) ;
33+ } ) ;
34+ } ) ;
3335
34- //it('assigns attributes correctly', function() {
35- //return expect(resultData(Person.find(1))).to.eventually
36- //.have.property('name', 'John')
37- //});
36+ it ( 'assigns attributes correctly' , function ( done ) {
37+ resultData ( Person . find ( 1 ) ) . then ( ( data ) => {
38+ expect ( data ) . to . have . property ( 'name' , 'John' ) ;
39+ done ( ) ;
40+ } ) ;
41+ } ) ;
3842
3943 describe ( 'when API response returns a different type than the caller' , function ( ) {
4044 before ( function ( ) {
@@ -70,7 +74,7 @@ describe('Model finders', function() {
7074 it ( 'returns a promise that resolves the correct instances' , function ( ) {
7175 return expect ( resultData ( Person . first ( ) ) ) . to . eventually
7276 . be . instanceof ( Person )
73- . have . property ( 'id' , '1' )
77+ . have . property ( 'id' , '1' ) ;
7478 } ) ;
7579 } ) ;
7680
@@ -84,11 +88,14 @@ describe('Model finders', function() {
8488 } ) ;
8589 } ) ;
8690
87- //it('returns a promise that resolves the correct instances', function() {
88- //return expect(resultData(Person.all())).to.eventually
89- //.all.be.instanceof(Person)
90- //.all.have.property('id', '1')
91- //});
91+ it ( 'returns a promise that resolves the correct instances' , function ( done ) {
92+ resultData ( Person . all ( ) ) . then ( ( data ) => {
93+ expect ( data . length ) . to . eq ( 1 ) ;
94+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
95+ expect ( data [ 0 ] ) . to . have . property ( 'id' , '1' ) ;
96+ done ( ) ;
97+ } ) ;
98+ } ) ;
9299
93100 describe ( 'response includes a meta payload' , function ( ) {
94101 beforeEach ( function ( ) {
@@ -123,11 +130,14 @@ describe('Model finders', function() {
123130 } ) ;
124131 } ) ;
125132
126- //it('queries correctly', function() {
127- //return expect(resultData(Person.page(2).all())).to.eventually
128- //.all.be.instanceof(Person)
129- //.all.have.property('id', '2')
130- //});
133+ it ( 'queries correctly' , function ( done ) {
134+ resultData ( Person . page ( 2 ) . all ( ) ) . then ( ( data ) => {
135+ expect ( data . length ) . to . eq ( 1 )
136+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
137+ expect ( data [ 0 ] ) . to . have . property ( 'id' , '2' ) ;
138+ done ( ) ;
139+ } ) ;
140+ } ) ;
131141
132142 describe ( 'when merging association #page' , function ( ) {
133143 before ( function ( ) {
@@ -139,12 +149,15 @@ describe('Model finders', function() {
139149 } ) ;
140150 } ) ;
141151
142- //it('queries correctly', function() {
143- //let bookScope = Book.page(10);
144- //let personScope = Person.page(5).merge({ books: bookScope });
145- //return expect(resultData(personScope.all())).to.eventually
146- //.all.be.instanceof(Person)
147- //});
152+ it ( 'queries correctly' , function ( done ) {
153+ let bookScope = Book . page ( 10 ) ;
154+ let personScope = Person . page ( 5 ) . merge ( { books : bookScope } ) ;
155+ resultData ( personScope . all ( ) ) . then ( ( data ) => {
156+ expect ( data . length ) . to . eq ( 1 ) ;
157+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
158+ done ( ) ;
159+ } ) ;
160+ } ) ;
148161 } ) ;
149162 } ) ;
150163
@@ -157,10 +170,13 @@ describe('Model finders', function() {
157170 } ) ;
158171 } ) ;
159172
160- //it('queries correctly', function() {
161- //return expect(resultData(Author.per(5).all())).to.eventually
162- //.all.be.instanceof(Person)
163- //});
173+ it ( 'queries correctly' , function ( done ) {
174+ resultData ( Author . per ( 5 ) . all ( ) ) . then ( ( data ) => {
175+ expect ( data . length ) . to . eq ( 1 ) ;
176+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
177+ done ( ) ;
178+ } ) ;
179+ } ) ;
164180
165181 describe ( 'when merging association #per' , function ( ) {
166182 before ( function ( ) {
@@ -172,12 +188,15 @@ describe('Model finders', function() {
172188 } ) ;
173189 } ) ;
174190
175- //it('queries correctly', function() {
176- //let bookScope = Book.per(2);
177- //let personScope = Person.per(5).merge({ books: bookScope });
178- //return expect(resultData(personScope.all())).to.eventually
179- //.all.be.instanceof(Person)
180- //});
191+ it ( 'queries correctly' , function ( done ) {
192+ let bookScope = Book . per ( 2 ) ;
193+ let personScope = Person . per ( 5 ) . merge ( { books : bookScope } ) ;
194+ resultData ( personScope . all ( ) ) . then ( ( data ) => {
195+ expect ( data . length ) . to . eq ( 1 ) ;
196+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
197+ done ( ) ;
198+ } ) ;
199+ } ) ;
181200 } ) ;
182201 } ) ;
183202
@@ -190,11 +209,14 @@ describe('Model finders', function() {
190209 } ) ;
191210 } ) ;
192211
193- //it('queries correctly', function() {
194- //return expect(resultData(Person.order('foo').order({ bar: 'desc' }).all())).to.eventually
195- //.all.be.instanceof(Person)
196- //.all.have.property('id', '2')
197- //});
212+ it ( 'queries correctly' , function ( done ) {
213+ resultData ( Person . order ( 'foo' ) . order ( { bar : 'desc' } ) . all ( ) ) . then ( ( data ) => {
214+ expect ( data . length ) . to . eq ( 1 ) ;
215+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
216+ expect ( data [ 0 ] ) . to . have . property ( 'id' , '2' ) ;
217+ done ( ) ;
218+ } ) ;
219+ } ) ;
198220
199221 describe ( 'when merging association #order' , function ( ) {
200222 before ( function ( ) {
@@ -206,14 +228,17 @@ describe('Model finders', function() {
206228 } ) ;
207229 } ) ;
208230
209- //it('queries correctly', function() {
210- //let bookScope = Book.order('title').order({ pages: 'desc' });
211- //let scope = Person.order('foo');
212- //scope = scope.merge({ books: bookScope })
213- //return expect(resultData(scope.all())).to.eventually
214- //.all.be.instanceof(Person)
215- //.all.have.property('id', '2')
216- //});
231+ it ( 'queries correctly' , function ( done ) {
232+ let bookScope = Book . order ( 'title' ) . order ( { pages : 'desc' } ) ;
233+ let scope = Person . order ( 'foo' ) ;
234+ scope = scope . merge ( { books : bookScope } )
235+ resultData ( scope . all ( ) ) . then ( ( data ) => {
236+ expect ( data . length ) . to . eq ( 1 ) ;
237+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
238+ expect ( data [ 0 ] ) . to . have . property ( 'id' , '2' ) ;
239+ done ( ) ;
240+ } ) ;
241+ } ) ;
217242 } ) ;
218243 } ) ;
219244
@@ -226,11 +251,14 @@ describe('Model finders', function() {
226251 } ) ;
227252 } ) ;
228253
229- //it('queries correctly', function() {
230- //return expect(resultData(Person.where({ id: 2 }).where({ a: 'b' }).all())).to.eventually
231- //.all.be.instanceof(Person)
232- //.all.have.property('id', '2')
233- //});
254+ it ( 'queries correctly' , function ( done ) {
255+ resultData ( Person . where ( { id : 2 } ) . where ( { a : 'b' } ) . all ( ) ) . then ( ( data ) => {
256+ expect ( data . length ) . to . eq ( 1 ) ;
257+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
258+ expect ( data [ 0 ] ) . to . have . property ( 'id' , '2' ) ;
259+ done ( ) ;
260+ } ) ;
261+ } ) ;
234262
235263 describe ( 'when merging association #where' , function ( ) {
236264 before ( function ( ) {
@@ -242,12 +270,16 @@ describe('Model finders', function() {
242270 } ) ;
243271 } ) ;
244272
245- //it('queries correctly', function() {
246- //let bookScope = Book.where({ title: 'It' });
247- //let personScope = Person.where({id : 1 }).merge({ books: bookScope });
248- //return expect(resultData(personScope.all())).to.eventually
249- //.all.be.instanceof(Person)
250- //});
273+ it ( 'queries correctly' , function ( done ) {
274+ let bookScope = Book . where ( { title : 'It' } ) ;
275+ let personScope = Person . where ( { id : 1 } ) . merge ( { books : bookScope } ) ;
276+
277+ resultData ( personScope . all ( ) ) . then ( ( data ) => {
278+ expect ( data . length ) . to . eq ( 1 ) ;
279+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
280+ done ( ) ;
281+ } ) ;
282+ } ) ;
251283 } ) ;
252284 } ) ;
253285
@@ -260,11 +292,15 @@ describe('Model finders', function() {
260292 } ) ;
261293 } ) ;
262294
263- //it('queries correctly', function() {
264- //let scope = Person.stats({ total: ['count', 'sum'] });
265- //return expect(resultData(scope.all())).to.eventually
266- //.all.be.instanceof(Person)
267- //});
295+ it ( 'queries correctly' , function ( done ) {
296+ let scope = Person . stats ( { total : [ 'count' , 'sum' ] } ) ;
297+
298+ resultData ( scope . all ( ) ) . then ( ( data ) => {
299+ expect ( data . length ) . to . eq ( 1 ) ;
300+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
301+ done ( ) ;
302+ } ) ;
303+ } ) ;
268304
269305 describe ( 'when merging association #stats' , function ( ) {
270306 before ( function ( ) {
@@ -276,14 +312,17 @@ describe('Model finders', function() {
276312 } ) ;
277313 } ) ;
278314
279- // it('queries correctly', function() {
280- // let bookScope = Book.stats({ pages: ['average'] });
281- // let scope = Person.stats({ total: ['count', 'sum'] });
282- // scope = scope.merge({ books: bookScope });
315+ it ( 'queries correctly' , function ( done ) {
316+ let bookScope = Book . stats ( { pages : [ 'average' ] } ) ;
317+ let scope = Person . stats ( { total : [ 'count' , 'sum' ] } ) ;
318+ scope = scope . merge ( { books : bookScope } ) ;
283319
284- //return expect(resultData(scope.all())).to.eventually
285- //.all.be.instanceof(Person)
286- //});
320+ resultData ( scope . all ( ) ) . then ( ( data ) => {
321+ expect ( data . length ) . to . eq ( 1 ) ;
322+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
323+ done ( ) ;
324+ } ) ;
325+ } ) ;
287326 } ) ;
288327 } ) ;
289328
@@ -296,11 +335,14 @@ describe('Model finders', function() {
296335 } ) ;
297336 } ) ;
298337
299- //it('queries correctly', function() {
300- //return expect(resultData(Person.select({ people: ['name', 'age'] }).all())).to.eventually
301- //.all.be.instanceof(Person)
302- //.all.have.property('id', '2')
303- //});
338+ it ( 'queries correctly' , function ( done ) {
339+ resultData ( Person . select ( { people : [ 'name' , 'age' ] } ) . all ( ) ) . then ( ( data ) => {
340+ expect ( data . length ) . to . eq ( 1 ) ;
341+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
342+ expect ( data [ 0 ] ) . to . have . property ( 'id' , '2' ) ;
343+ done ( ) ;
344+ } ) ;
345+ } ) ;
304346 } ) ;
305347
306348 describe ( '#select_extra' , function ( ) {
@@ -312,11 +354,14 @@ describe('Model finders', function() {
312354 } ) ;
313355 } ) ;
314356
315- //it('queries correctly', function() {
316- //return expect(resultData(Person.selectExtra({ people: ['net_worth', 'best_friend'] }).all())).to.eventually
317- //.all.be.instanceof(Person)
318- //.all.have.property('id', '2')
319- //});
357+ it ( 'queries correctly' , function ( done ) {
358+ resultData ( Person . selectExtra ( { people : [ 'net_worth' , 'best_friend' ] } ) . all ( ) ) . then ( ( data ) => {
359+ expect ( data . length ) . to . eq ( 1 ) ;
360+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
361+ expect ( data [ 0 ] ) . to . have . property ( 'id' , '2' ) ;
362+ done ( ) ;
363+ } ) ;
364+ } ) ;
320365 } ) ;
321366
322367 describe ( '#includes' , function ( ) {
@@ -331,10 +376,12 @@ describe('Model finders', function() {
331376 } ) ;
332377 } ) ;
333378
334- //it('queries correctly', function() {
335- //return expect(resultData(Person.includes({ a: ['b', { c: 'd' }] }).all())).to.eventually
336- //.all.be.instanceof(Person)
337- //.all.have.property('id', '2')
338- //});
379+ it ( 'queries correctly' , function ( ) {
380+ resultData ( Person . includes ( { a : [ 'b' , { c : 'd' } ] } ) . all ( ) ) . then ( ( data ) => {
381+ expect ( data . length ) . to . eq ( 1 ) ;
382+ expect ( data [ 0 ] ) . to . be . instanceof ( Person ) ;
383+ expect ( data [ 0 ] ) . to . have . property ( 'id' , '2' ) ;
384+ } ) ;
385+ } ) ;
339386 } ) ;
340387} ) ;
0 commit comments