@@ -382,7 +382,7 @@ describe('MockFirestoreCollection', function () {
382382 } ) . catch ( done ) ;
383383 } ) ;
384384
385- it ( 'returns documents ordered by date ' , function ( done ) {
385+ it ( 'returns documents ordered by timestamp ' , function ( done ) {
386386 db . collection ( 'group' ) . doc ( ) . create ( {
387387 name : 'a' ,
388388 date : Timestamp . fromMillis ( 1000 )
@@ -411,6 +411,36 @@ describe('MockFirestoreCollection', function () {
411411 } ) . catch ( done ) ;
412412 db . flush ( ) ;
413413 } ) ;
414+
415+ it ( 'returns documents ordered by date' , function ( done ) {
416+ db . collection ( 'group' ) . doc ( ) . create ( {
417+ name : 'a' ,
418+ date : new Date ( 1000 )
419+ } ) . catch ( done ) ;
420+ db . flush ( ) ;
421+ db . collection ( 'group' ) . add ( {
422+ name : 'b' ,
423+ date : new Date ( 2000 )
424+ } ) . catch ( done ) ;
425+ db . flush ( ) ;
426+
427+ db . collection ( 'group' ) . orderBy ( 'date' , 'asc' ) . get ( ) . then ( function ( snap ) {
428+ expect ( snap . size ) . to . equal ( 2 ) ;
429+ expect ( snap . docs [ 0 ] . data ( ) . name ) . to . equal ( 'a' ) ;
430+ expect ( snap . docs [ 0 ] . data ( ) . date ) . to . have . property ( 'seconds' ) ;
431+ expect ( snap . docs [ 1 ] . data ( ) . name ) . to . equal ( 'b' ) ;
432+ expect ( snap . docs [ 1 ] . data ( ) . date ) . to . have . property ( 'seconds' ) ;
433+
434+ db . collection ( 'group' ) . orderBy ( 'date' , 'desc' ) . get ( ) . then ( function ( snap ) {
435+ expect ( snap . size ) . to . equal ( 2 ) ;
436+ expect ( snap . docs [ 0 ] . data ( ) . name ) . to . equal ( 'b' ) ;
437+ expect ( snap . docs [ 1 ] . data ( ) . name ) . to . equal ( 'a' ) ;
438+ done ( ) ;
439+ } ) . catch ( done ) ;
440+ db . flush ( ) ;
441+ } ) . catch ( done ) ;
442+ db . flush ( ) ;
443+ } ) ;
414444 } ) ;
415445
416446 describe ( '#limit' , function ( ) {
0 commit comments