@@ -13,7 +13,7 @@ import Test.Spec (Spec, describe, it)
13
13
import Test.Spec.Assertions (fail , shouldSatisfy )
14
14
15
15
import Test.Web.Firestore.OptionsUtils (buildTestOptions )
16
- import Web.Firestore (add , collection , deleteApp , firestore , getCollection , initializeApp )
16
+ import Web.Firestore (add , clearCollection , collection , deleteApp , firestore , getCollection , initializeApp )
17
17
import Web.Firestore.Blob (blob )
18
18
import Web.Firestore.CollectionPath (pathFromString )
19
19
import Web.Firestore.DocumentData (DocumentData (..))
@@ -203,3 +203,28 @@ suite = do
203
203
forEach querySnapshot (const $ pure unit)
204
204
deletePromise <- liftEffect $ deleteApp app
205
205
toAff deletePromise
206
+
207
+ it " clears a collection" do
208
+ testOptions <- buildTestOptions
209
+ eitherErrorApp <- liftEffect $ initializeApp testOptions (Just " firestore-test" )
210
+ case eitherErrorApp of
211
+ Left error -> fail $ show error
212
+ Right app -> do
213
+ eitherFirestoreInstance <- liftEffect $ firestore app
214
+ case eitherFirestoreInstance of
215
+ Left error -> fail $ show error
216
+ Right firestoreInstance -> do
217
+ maybeCollectionRef <- liftEffect $ sequence $ collection firestoreInstance <$> (pathFromString " collection" )
218
+ case maybeCollectionRef of
219
+ Nothing -> fail " invalid path"
220
+ Just collectionRef -> do
221
+ addPromise1 <- liftEffect $ add collectionRef document1
222
+ _ <- toAff addPromise1
223
+ addPromise2 <- liftEffect $ add collectionRef document2
224
+ _ <- toAff addPromise2
225
+ clearCollection collectionRef
226
+ getPromise <- liftEffect $ getCollection collectionRef Nothing
227
+ querySnapshot <- toAff getPromise
228
+ forEach querySnapshot (const $ fail " no document should be present now!" )
229
+ deletePromise <- liftEffect $ deleteApp app
230
+ toAff deletePromise
0 commit comments