1414 * limitations under the License.
1515 */
1616
17+ import { expect } from 'chai' ;
1718import extend from 'extend' ;
1819import * as gax from 'google-gax' ;
1920import is from 'is' ;
@@ -426,36 +427,37 @@ describe('instantiation', () => {
426427
427428 it ( 'exports all types' , ( ) => {
428429 // Ordering as per firestore.d.ts
429- assert . ok ( is . defined ( Firestore . Firestore ) ) ;
430+ expect ( ( Firestore . Firestore ) ) . to . exist ;
430431 assert . equal ( Firestore . Firestore . name , 'Firestore' ) ;
431- assert . ok ( is . defined ( Firestore . Timestamp ) ) ;
432+ expect ( ( Firestore . Timestamp ) ) . to . exist ;
432433 assert . equal ( Firestore . Timestamp . name , 'Timestamp' ) ;
433- assert . ok ( is . defined ( Firestore . GeoPoint ) ) ;
434+ expect ( ( Firestore . GeoPoint ) ) . to . exist ;
434435 assert . equal ( Firestore . GeoPoint . name , 'GeoPoint' ) ;
435- assert . ok ( is . defined ( Firestore . Transaction ) ) ;
436+ expect ( ( Firestore . Transaction ) ) . to . exist ;
436437 assert . equal ( Firestore . Transaction . name , 'Transaction' ) ;
437- assert . ok ( is . defined ( Firestore . WriteBatch ) ) ;
438+ expect ( ( Firestore . WriteBatch ) ) . to . exist ;
438439 assert . equal ( Firestore . WriteBatch . name , 'WriteBatch' ) ;
439- assert . ok ( is . defined ( Firestore . DocumentReference ) ) ;
440+ expect ( ( Firestore . DocumentReference ) ) . to . exist ;
440441 assert . equal ( Firestore . DocumentReference . name , 'DocumentReference' ) ;
441- assert . ok ( is . defined ( Firestore . WriteResult ) ) ;
442+ expect ( ( Firestore . WriteResult ) ) . to . exist ;
442443 assert . equal ( Firestore . WriteResult . name , 'WriteResult' ) ;
443- assert . ok ( is . defined ( Firestore . DocumentSnapshot ) ) ;
444+ expect ( ( Firestore . DocumentSnapshot ) ) . to . exist ;
444445 assert . equal ( Firestore . DocumentSnapshot . name , 'DocumentSnapshot' ) ;
445- assert . ok ( is . defined ( Firestore . QueryDocumentSnapshot ) ) ;
446+ expect ( ( Firestore . QueryDocumentSnapshot ) ) . to . exist ;
446447 assert . equal ( Firestore . QueryDocumentSnapshot . name , 'QueryDocumentSnapshot' ) ;
447- assert . ok ( is . defined ( Firestore . Query ) ) ;
448+ expect ( ( Firestore . Query ) ) . to . exist ;
448449 assert . equal ( Firestore . Query . name , 'Query' ) ;
449- assert . ok ( is . defined ( Firestore . QuerySnapshot ) ) ;
450+ expect ( Firestore . QuerySnapshot ) . to . exist ;
450451 assert . equal ( Firestore . QuerySnapshot . name , 'QuerySnapshot' ) ;
451- assert . ok ( is . defined ( Firestore . CollectionReference ) ) ;
452+ expect ( ( Firestore . CollectionReference ) ) . to . exist ;
452453 assert . equal ( Firestore . CollectionReference . name , 'CollectionReference' ) ;
453- assert . ok ( is . defined ( Firestore . FieldValue ) ) ;
454+ expect ( ( Firestore . FieldValue ) ) . to . exist ;
454455 assert . equal ( Firestore . FieldValue . name , 'FieldValue' ) ;
455- assert . ok ( is . defined ( Firestore . FieldPath ) ) ;
456+ expect ( ( Firestore . FieldPath ) ) . to . exist ;
456457 assert . equal ( Firestore . Firestore . name , 'Firestore' ) ;
457- assert . ok ( ! Firestore . FieldValue . serverTimestamp ( ) . isEqual (
458- Firestore . FieldValue . delete ( ) ) ) ;
458+ expect ( Firestore . FieldValue . serverTimestamp ( ) . isEqual (
459+ Firestore . FieldValue . delete ( ) ) )
460+ . to . be . false ;
459461 } ) ;
460462} ) ;
461463
@@ -505,8 +507,9 @@ describe('snapshot_() method', () => {
505507 assert . equal (
506508 data . geoPointValue . toString ( ) ,
507509 'GeoPoint { latitude: 50.1430847, longitude: -122.947778 }' ) ;
508- assert . ok ( data . geoPointValue . isEqual (
509- new Firestore . GeoPoint ( 50.1430847 , - 122.947778 ) ) ) ;
510+ expect ( data . geoPointValue . isEqual (
511+ new Firestore . GeoPoint ( 50.1430847 , - 122.947778 ) ) )
512+ . to . be . true ;
510513 }
511514
512515 beforeEach ( ( ) => {
@@ -529,9 +532,9 @@ describe('snapshot_() method', () => {
529532
530533 assert . equal ( true , doc . exists ) ;
531534 assert . deepStrictEqual ( { foo : bytesData } , doc . data ( ) ) ;
532- assert . ok ( doc . createTime . isEqual ( new Firestore . Timestamp ( 1 , 2 ) ) ) ;
533- assert . ok ( doc . updateTime . isEqual ( new Firestore . Timestamp ( 3 , 4 ) ) ) ;
534- assert . ok ( doc . readTime . isEqual ( new Firestore . Timestamp ( 5 , 6 ) ) ) ;
535+ expect ( doc . createTime . isEqual ( new Firestore . Timestamp ( 1 , 2 ) ) ) . to . be . true ;
536+ expect ( doc . updateTime . isEqual ( new Firestore . Timestamp ( 3 , 4 ) ) ) . to . be . true ;
537+ expect ( doc . readTime . isEqual ( new Firestore . Timestamp ( 5 , 6 ) ) ) . to . be . true ;
535538 } ) ;
536539
537540 it ( 'handles Proto3 JSON together with existing types' , ( ) => {
@@ -559,9 +562,10 @@ describe('snapshot_() method', () => {
559562 b : Firestore . Timestamp . fromDate ( new Date ( '1985-03-18T07:20:00.000Z' ) ) ,
560563 c : bytesData ,
561564 } ) ;
562- assert . ok ( doc . createTime . isEqual ( new Firestore . Timestamp ( 1 , 2000000 ) ) ) ;
563- assert . ok ( doc . updateTime . isEqual ( new Firestore . Timestamp ( 3 , 4000 ) ) ) ;
564- assert . ok ( doc . readTime . isEqual ( new Firestore . Timestamp ( 5 , 6 ) ) ) ;
565+ expect ( doc . createTime . isEqual ( new Firestore . Timestamp ( 1 , 2000000 ) ) )
566+ . to . be . true ;
567+ expect ( doc . updateTime . isEqual ( new Firestore . Timestamp ( 3 , 4000 ) ) ) . to . be . true ;
568+ expect ( doc . readTime . isEqual ( new Firestore . Timestamp ( 5 , 6 ) ) ) . to . be . true ;
565569 } ) ;
566570
567571 it ( 'deserializes all supported types from Protobuf JS' , ( ) => {
@@ -620,7 +624,7 @@ describe('snapshot_() method', () => {
620624 '1970-01-01T00:00:05.000000006Z' , 'json' ) ;
621625
622626 assert . equal ( false , doc . exists ) ;
623- assert . ok ( doc . readTime . isEqual ( new Firestore . Timestamp ( 5 , 6 ) ) ) ;
627+ expect ( doc . readTime . isEqual ( new Firestore . Timestamp ( 5 , 6 ) ) ) . to . be . true ;
624628 } ) ;
625629
626630 it ( 'handles invalid encoding format ' , ( ) => {
@@ -643,7 +647,7 @@ describe('doc() method', () => {
643647
644648 it ( 'returns DocumentReference' , ( ) => {
645649 const documentRef = firestore . doc ( 'collectionId/documentId' ) ;
646- assert . ok ( documentRef instanceof Firestore . DocumentReference ) ;
650+ expect ( documentRef ) . to . be . an . instanceOf ( Firestore . DocumentReference ) ;
647651 } ) ;
648652
649653 it ( 'requires document path' , ( ) => {
@@ -682,7 +686,7 @@ describe('collection() method', () => {
682686
683687 it ( 'returns collection' , ( ) => {
684688 const collection = firestore . collection ( 'col1/doc1/col2' ) ;
685- assert . ok ( is . instance ( collection , Firestore . CollectionReference ) ) ;
689+ expect ( collection ) . to . be . an . instanceOf ( Firestore . CollectionReference ) ;
686690 } ) ;
687691
688692 it ( 'requires collection id' , ( ) => {
@@ -700,8 +704,8 @@ describe('collection() method', () => {
700704
701705 it ( 'exposes properties' , ( ) => {
702706 const collection = firestore . collection ( 'collectionId' ) ;
703- assert . ok ( collection . id ) ;
704- assert . ok ( collection . doc ) ;
707+ expect ( collection . id ) . to . exist ;
708+ expect ( collection . doc ) . to . exist ;
705709 assert . equal ( collection . id , 'collectionId' ) ;
706710 } ) ;
707711} ) ;
@@ -736,10 +740,10 @@ describe('getAll() method', () => {
736740 const doc = arguments [ i + 1 ] ;
737741
738742 if ( doc . found ) {
739- assert . ok ( result [ i ] . exists ) ;
743+ expect ( result [ i ] . exists ) . to . be . true ;
740744 assert . equal ( result [ i ] . ref . formattedName , doc . found . name ) ;
741745 } else {
742- assert . ok ( ! result [ i ] . exists ) ;
746+ expect ( result [ i ] . exists ) . to . be . false ;
743747 assert . equal ( result [ i ] . ref . formattedName , doc . missing ) ;
744748 }
745749 }
0 commit comments