@dereekb/firebase 13.10.8 → 13.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/test/index.cjs.js +139 -104
- package/test/index.esm.js +139 -104
- package/test/package.json +6 -6
- package/test/src/lib/client/firebase.d.ts +13 -0
- package/test/src/lib/common/firestore/firestore.d.ts +5 -3
- package/test/src/lib/common/mock/mock.item.collection.fixture.d.ts +6 -0
- package/test/src/lib/common/mock/mock.item.d.ts +54 -11
- package/test/src/lib/common/mock/mock.item.query.d.ts +8 -2
- package/test/src/lib/common/mock/mock.item.service.d.ts +3 -0
- package/test/src/lib/common/mock/mock.item.storage.fixture.d.ts +3 -0
- package/test/src/lib/common/storage/storage.d.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.11.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"exports": {
|
|
6
6
|
"./test": {
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@dereekb/util": "13.
|
|
22
|
-
"@dereekb/date": "13.
|
|
23
|
-
"@dereekb/model": "13.
|
|
24
|
-
"@dereekb/rxjs": "13.
|
|
21
|
+
"@dereekb/util": "13.11.0",
|
|
22
|
+
"@dereekb/date": "13.11.0",
|
|
23
|
+
"@dereekb/model": "13.11.0",
|
|
24
|
+
"@dereekb/rxjs": "13.11.0",
|
|
25
25
|
"@firebase/rules-unit-testing": "5.0.0",
|
|
26
26
|
"arktype": "^2.2.0",
|
|
27
27
|
"date-fns": "^4.1.0",
|
package/test/index.cjs.js
CHANGED
|
@@ -260,6 +260,7 @@ function _ts_generator$6(thisArg, body) {
|
|
|
260
260
|
* ```
|
|
261
261
|
*
|
|
262
262
|
* @param driver - The base driver to wrap with fuzzing behavior.
|
|
263
|
+
* @returns A {@link TestingFirestoreAccessorDriver} with `collection`, `subcollection`, and `collectionGroup` rewired to use fuzzed paths, plus helpers to inspect the fuzz map.
|
|
263
264
|
*/ function makeTestingFirestoreAccesorDriver(driver) {
|
|
264
265
|
var fuzzerKey = 0;
|
|
265
266
|
var time = new Date().getTime();
|
|
@@ -316,8 +317,8 @@ function _ts_generator$6(thisArg, body) {
|
|
|
316
317
|
/**
|
|
317
318
|
* Extends the input drivers to generate new drivers for a testing environment.
|
|
318
319
|
*
|
|
319
|
-
* @param drivers
|
|
320
|
-
* @returns
|
|
320
|
+
* @param drivers - The base Firestore drivers to wrap.
|
|
321
|
+
* @returns A {@link TestingFirestoreDrivers} marked with `firestoreDriverType: 'testing'` and a wrapped accessor driver from {@link makeTestingFirestoreAccesorDriver}.
|
|
321
322
|
*/ function makeTestingFirestoreDrivers(drivers) {
|
|
322
323
|
return _object_spread_props$2(_object_spread$3({}, drivers), {
|
|
323
324
|
firestoreDriverType: 'testing',
|
|
@@ -413,6 +414,7 @@ var bucketTestNameKey = 0;
|
|
|
413
414
|
*
|
|
414
415
|
* @param driver - The base storage accessor driver to wrap.
|
|
415
416
|
* @param config - Optional configuration controlling test bucket behavior.
|
|
417
|
+
* @returns A driver with the same surface as `driver`, but with `getDefaultBucket` overridden to return a unique test bucket name when {@link MakeTestingFirebaseStorageAccessorDriverConfig.useTestDefaultBucket} requires it.
|
|
416
418
|
*/ function makeTestingFirebaseStorageAccesorDriver(driver, config) {
|
|
417
419
|
var useTestDefaultBucket = (config !== null && config !== void 0 ? config : {}).useTestDefaultBucket;
|
|
418
420
|
// The default bucket is only used if another bucket is not input.
|
|
@@ -429,8 +431,9 @@ var bucketTestNameKey = 0;
|
|
|
429
431
|
/**
|
|
430
432
|
* Extends the input drivers to generate new drivers for a testing environment.
|
|
431
433
|
*
|
|
432
|
-
* @param drivers
|
|
433
|
-
* @
|
|
434
|
+
* @param drivers - The base Firebase Storage drivers to wrap.
|
|
435
|
+
* @param config - Optional config forwarded to {@link makeTestingFirebaseStorageAccesorDriver}; controls test-bucket override behavior.
|
|
436
|
+
* @returns A {@link TestingFirebaseStorageDrivers} marked with `storageDriverType: 'testing'` and a wrapped accessor driver.
|
|
434
437
|
*/ function makeTestingFirebaseStorageDrivers(drivers, config) {
|
|
435
438
|
return _object_spread_props$1(_object_spread$2({}, drivers), {
|
|
436
439
|
storageDriverType: 'testing',
|
|
@@ -848,6 +851,11 @@ function _ts_generator$5(thisArg, body) {
|
|
|
848
851
|
*
|
|
849
852
|
* Combines the Firestore client drivers with the rules test environment and context
|
|
850
853
|
* to produce a context suitable for client-side Firestore tests.
|
|
854
|
+
*
|
|
855
|
+
* @param drivers - Testing Firestore drivers used to back the context (typically with collection name fuzzing).
|
|
856
|
+
* @param rulesTestEnvironment - The shared `@firebase/rules-unit-testing` environment for the suite.
|
|
857
|
+
* @param rulesTestContext - The per-test rules context (authenticated or unauthenticated) used to obtain the Firestore instance.
|
|
858
|
+
* @returns A {@link RulesUnitTestTestFirestoreContext} that exposes the rules-test environment and context alongside the standard Firestore context.
|
|
851
859
|
*/ function makeRulesTestFirestoreContext(drivers, rulesTestEnvironment, rulesTestContext) {
|
|
852
860
|
var context = _object_spread_props(_object_spread$1({}, firebase.firestoreContextFactory(drivers)(rulesTestContext.firestore())), {
|
|
853
861
|
drivers: drivers,
|
|
@@ -861,6 +869,11 @@ function _ts_generator$5(thisArg, body) {
|
|
|
861
869
|
*
|
|
862
870
|
* Combines the Storage client drivers with the rules test environment and context
|
|
863
871
|
* to produce a context suitable for client-side Firebase Storage tests.
|
|
872
|
+
*
|
|
873
|
+
* @param drivers - Testing Firebase Storage drivers used to back the context (typically with a unique test bucket).
|
|
874
|
+
* @param rulesTestEnvironment - The shared `@firebase/rules-unit-testing` environment for the suite.
|
|
875
|
+
* @param rulesTestContext - The per-test rules context used to obtain the Storage instance.
|
|
876
|
+
* @returns A {@link RulesUnitTestTestFirebaseStorageContext} that exposes the rules-test environment and context alongside the standard Storage context.
|
|
864
877
|
*/ function makeRulesTestFirebaseStorageContext(drivers, rulesTestEnvironment, rulesTestContext) {
|
|
865
878
|
var context = _object_spread_props(_object_spread$1({}, firebase.firebaseStorageContextFactory(drivers)(rulesTestContext.storage())), {
|
|
866
879
|
drivers: drivers,
|
|
@@ -944,6 +957,9 @@ function _ts_generator$5(thisArg, body) {
|
|
|
944
957
|
* preventing interference between parallel workers sharing the same Firebase Storage emulator. The Storage
|
|
945
958
|
* emulator maintains rules globally (not per-project), so concurrent `setRules` calls from multiple workers
|
|
946
959
|
* can momentarily leave the emulator in a transitional state that causes `storage/unauthorized` errors.
|
|
960
|
+
*
|
|
961
|
+
* @param inputConfig - Optional partial config; `testEnvironment` defaults to an empty object and `rulesContext` defaults to undefined (unauthenticated).
|
|
962
|
+
* @returns A function that, given a `buildTests` callback, registers Vitest hooks (`beforeAll`/`afterAll`/`beforeEach`/`afterEach`) and invokes the callback with a {@link RulesUnitTestFirebaseTestingContextFixture}.
|
|
947
963
|
*/ var firebaseRulesUnitTestBuilder = function firebaseRulesUnitTestBuilder(inputConfig) {
|
|
948
964
|
var _ref;
|
|
949
965
|
var config = {
|
|
@@ -1255,8 +1271,8 @@ function _is_native_reflect_construct$4() {
|
|
|
1255
1271
|
/**
|
|
1256
1272
|
* Used to build a mockItemCollection from a firestore instance with a converter setup.
|
|
1257
1273
|
*
|
|
1258
|
-
* @param
|
|
1259
|
-
* @returns
|
|
1274
|
+
* @param context - The Firestore context to resolve the root collection against.
|
|
1275
|
+
* @returns A typed {@link CollectionReference} for the root MockItem collection.
|
|
1260
1276
|
*/ function mockItemCollectionReference(context) {
|
|
1261
1277
|
return context.collection(mockItemIdentity.collectionName);
|
|
1262
1278
|
}
|
|
@@ -1268,6 +1284,9 @@ function _is_native_reflect_construct$4() {
|
|
|
1268
1284
|
* const collection = mockItemFirestoreCollection(firestoreContext);
|
|
1269
1285
|
* const doc = collection.documentAccessor().newDocument();
|
|
1270
1286
|
* ```
|
|
1287
|
+
*
|
|
1288
|
+
* @param firestoreContext - The Firestore context (test or production) used to resolve the underlying collection reference.
|
|
1289
|
+
* @returns A {@link MockItemFirestoreCollection} wired with the {@link mockItemConverter} and {@link mockItemIdentity}.
|
|
1271
1290
|
*/ function mockItemFirestoreCollection(firestoreContext) {
|
|
1272
1291
|
return firestoreContext.firestoreCollection({
|
|
1273
1292
|
converter: mockItemConverter,
|
|
@@ -1372,13 +1391,11 @@ function _is_native_reflect_construct$4() {
|
|
|
1372
1391
|
})
|
|
1373
1392
|
});
|
|
1374
1393
|
/**
|
|
1375
|
-
* Used to build a mockItemCollection from a firestore instance with a converter setup.
|
|
1376
|
-
*
|
|
1377
|
-
* @param firestore
|
|
1378
|
-
* @returns
|
|
1379
|
-
*/ /**
|
|
1380
1394
|
* Creates a factory that produces {@link CollectionReference} instances for {@link MockItemPrivate}
|
|
1381
1395
|
* subcollections under a given {@link MockItemDocument} parent.
|
|
1396
|
+
*
|
|
1397
|
+
* @param context - The Firestore context used to resolve subcollections.
|
|
1398
|
+
* @returns A function that, given a parent {@link MockItemDocument}, returns a typed {@link CollectionReference} for that parent's MockItemPrivate subcollection.
|
|
1382
1399
|
*/ function mockItemPrivateCollectionReferenceFactory(context) {
|
|
1383
1400
|
return function(parent) {
|
|
1384
1401
|
return context.subcollection(parent.documentRef, mockItemPrivateIdentity.collectionName);
|
|
@@ -1386,6 +1403,9 @@ function _is_native_reflect_construct$4() {
|
|
|
1386
1403
|
}
|
|
1387
1404
|
/**
|
|
1388
1405
|
* Creates a factory for producing {@link MockItemPrivateFirestoreCollection} instances bound to a parent {@link MockItemDocument}.
|
|
1406
|
+
*
|
|
1407
|
+
* @param firestoreContext - The Firestore context used to resolve the underlying subcollection.
|
|
1408
|
+
* @returns A factory that, given a parent {@link MockItemDocument}, returns a single-item collection wired with {@link mockItemPrivateConverter}.
|
|
1389
1409
|
*/ function mockItemPrivateFirestoreCollection(firestoreContext) {
|
|
1390
1410
|
var factory = mockItemPrivateCollectionReferenceFactory(firestoreContext);
|
|
1391
1411
|
return function(parent) {
|
|
@@ -1403,11 +1423,17 @@ function _is_native_reflect_construct$4() {
|
|
|
1403
1423
|
}
|
|
1404
1424
|
/**
|
|
1405
1425
|
* Creates a {@link CollectionGroup} reference for querying all {@link MockItemPrivate} documents across parents.
|
|
1426
|
+
*
|
|
1427
|
+
* @param context - The Firestore context used to resolve the collection group.
|
|
1428
|
+
* @returns A typed {@link CollectionGroup} reference for the MockItemPrivate collection name.
|
|
1406
1429
|
*/ function mockItemPrivateCollectionReference(context) {
|
|
1407
1430
|
return context.collectionGroup(mockItemPrivateIdentity.collectionName);
|
|
1408
1431
|
}
|
|
1409
1432
|
/**
|
|
1410
1433
|
* Creates a {@link MockItemPrivateFirestoreCollectionGroup} for cross-parent queries on {@link MockItemPrivate}.
|
|
1434
|
+
*
|
|
1435
|
+
* @param firestoreContext - The Firestore context used to resolve the underlying collection group reference.
|
|
1436
|
+
* @returns A typed {@link MockItemPrivateFirestoreCollectionGroup} wired with the {@link mockItemPrivateConverter}.
|
|
1411
1437
|
*/ function mockItemPrivateFirestoreCollectionGroup(firestoreContext) {
|
|
1412
1438
|
return firestoreContext.firestoreCollectionGroup({
|
|
1413
1439
|
modelIdentity: mockItemPrivateIdentity,
|
|
@@ -1460,10 +1486,11 @@ var mockItemUserIdentifier = '0';
|
|
|
1460
1486
|
})
|
|
1461
1487
|
});
|
|
1462
1488
|
/**
|
|
1463
|
-
*
|
|
1489
|
+
* Creates a factory that produces {@link CollectionReference} instances for {@link MockItemUser}
|
|
1490
|
+
* subcollections under a given {@link MockItemDocument} parent.
|
|
1464
1491
|
*
|
|
1465
|
-
* @param
|
|
1466
|
-
* @returns
|
|
1492
|
+
* @param context - The Firestore context used to resolve subcollections.
|
|
1493
|
+
* @returns A function that, given a parent {@link MockItemDocument}, returns a typed {@link CollectionReference} for that parent's MockItemUser subcollection.
|
|
1467
1494
|
*/ function mockItemUserCollectionReferenceFactory(context) {
|
|
1468
1495
|
return function(parent) {
|
|
1469
1496
|
return context.subcollection(parent.documentRef, mockItemUserCollectionName);
|
|
@@ -1474,6 +1501,9 @@ var mockItemUserIdentifier = '0';
|
|
|
1474
1501
|
*/ var mockItemUserAccessorFactory = firebase.copyUserRelatedDataAccessorFactoryFunction();
|
|
1475
1502
|
/**
|
|
1476
1503
|
* Creates a factory for producing {@link MockItemUserFirestoreCollection} instances bound to a parent {@link MockItemDocument}.
|
|
1504
|
+
*
|
|
1505
|
+
* @param firestoreContext - The Firestore context used to resolve the underlying subcollection.
|
|
1506
|
+
* @returns A factory that, given a parent {@link MockItemDocument}, returns a per-parent collection wired with {@link mockItemUserConverter} and {@link mockItemUserAccessorFactory}.
|
|
1477
1507
|
*/ function mockItemUserFirestoreCollection(firestoreContext) {
|
|
1478
1508
|
var factory = mockItemUserCollectionReferenceFactory(firestoreContext);
|
|
1479
1509
|
return function(parent) {
|
|
@@ -1492,11 +1522,17 @@ var mockItemUserIdentifier = '0';
|
|
|
1492
1522
|
}
|
|
1493
1523
|
/**
|
|
1494
1524
|
* Creates a {@link CollectionGroup} reference for querying all {@link MockItemUser} documents across parents.
|
|
1525
|
+
*
|
|
1526
|
+
* @param context - The Firestore context used to resolve the collection group.
|
|
1527
|
+
* @returns A typed {@link CollectionGroup} reference for the MockItemUser collection name.
|
|
1495
1528
|
*/ function mockItemUserCollectionReference(context) {
|
|
1496
1529
|
return context.collectionGroup(mockItemUserCollectionName);
|
|
1497
1530
|
}
|
|
1498
1531
|
/**
|
|
1499
1532
|
* Creates a {@link MockItemUserFirestoreCollectionGroup} for cross-parent queries on {@link MockItemUser}.
|
|
1533
|
+
*
|
|
1534
|
+
* @param firestoreContext - The Firestore context used to resolve the underlying collection group reference.
|
|
1535
|
+
* @returns A typed {@link MockItemUserFirestoreCollectionGroup} wired with the {@link mockItemUserConverter} and {@link mockItemUserAccessorFactory}.
|
|
1500
1536
|
*/ function mockItemUserFirestoreCollectionGroup(firestoreContext) {
|
|
1501
1537
|
return firestoreContext.firestoreCollectionGroup({
|
|
1502
1538
|
modelIdentity: mockItemUserIdentity,
|
|
@@ -1546,6 +1582,9 @@ var mockItemUserIdentifier = '0';
|
|
|
1546
1582
|
/**
|
|
1547
1583
|
* Creates a factory that produces {@link CollectionReference} instances for {@link MockItemSubItem}
|
|
1548
1584
|
* subcollections under a given {@link MockItemDocument} parent.
|
|
1585
|
+
*
|
|
1586
|
+
* @param context - The Firestore context used to resolve subcollections.
|
|
1587
|
+
* @returns A function that, given a parent {@link MockItemDocument}, returns a typed {@link CollectionReference} for that parent's MockItemSubItem subcollection.
|
|
1549
1588
|
*/ function mockItemSubItemCollectionReferenceFactory(context) {
|
|
1550
1589
|
return function(parent) {
|
|
1551
1590
|
return context.subcollection(parent.documentRef, mockItemSubItemIdentity.collectionName);
|
|
@@ -1553,6 +1592,9 @@ var mockItemUserIdentifier = '0';
|
|
|
1553
1592
|
}
|
|
1554
1593
|
/**
|
|
1555
1594
|
* Creates a factory for producing {@link MockItemSubItemFirestoreCollection} instances bound to a parent {@link MockItemDocument}.
|
|
1595
|
+
*
|
|
1596
|
+
* @param firestoreContext - The Firestore context used to resolve the underlying subcollection.
|
|
1597
|
+
* @returns A factory that, given a parent {@link MockItemDocument}, returns a per-parent collection wired with {@link mockItemSubItemConverter}.
|
|
1556
1598
|
*/ function mockItemSubItemFirestoreCollection(firestoreContext) {
|
|
1557
1599
|
var factory = mockItemSubItemCollectionReferenceFactory(firestoreContext);
|
|
1558
1600
|
return function(parent) {
|
|
@@ -1570,11 +1612,17 @@ var mockItemUserIdentifier = '0';
|
|
|
1570
1612
|
}
|
|
1571
1613
|
/**
|
|
1572
1614
|
* Creates a {@link CollectionGroup} reference for querying all {@link MockItemSubItem} documents across parents.
|
|
1615
|
+
*
|
|
1616
|
+
* @param context - The Firestore context used to resolve the collection group.
|
|
1617
|
+
* @returns A typed {@link CollectionGroup} reference for the MockItemSubItem collection name.
|
|
1573
1618
|
*/ function mockItemSubItemCollectionReference(context) {
|
|
1574
1619
|
return context.collectionGroup(mockItemSubItemIdentity.collectionName);
|
|
1575
1620
|
}
|
|
1576
1621
|
/**
|
|
1577
1622
|
* Creates a {@link MockItemSubItemFirestoreCollectionGroup} for cross-parent queries on {@link MockItemSubItem}.
|
|
1623
|
+
*
|
|
1624
|
+
* @param firestoreContext - The Firestore context used to resolve the underlying collection group reference.
|
|
1625
|
+
* @returns A typed {@link MockItemSubItemFirestoreCollectionGroup} wired with the {@link mockItemSubItemConverter}.
|
|
1578
1626
|
*/ function mockItemSubItemFirestoreCollectionGroup(firestoreContext) {
|
|
1579
1627
|
return firestoreContext.firestoreCollectionGroup({
|
|
1580
1628
|
modelIdentity: mockItemSubItemIdentity,
|
|
@@ -1623,6 +1671,9 @@ var mockItemUserIdentifier = '0';
|
|
|
1623
1671
|
/**
|
|
1624
1672
|
* Creates a factory that produces {@link CollectionReference} instances for {@link MockItemSubItemDeep}
|
|
1625
1673
|
* subcollections under a given {@link MockItemSubItemDocument} parent.
|
|
1674
|
+
*
|
|
1675
|
+
* @param context - The Firestore context used to resolve subcollections.
|
|
1676
|
+
* @returns A function that, given a parent {@link MockItemSubItemDocument}, returns a typed {@link CollectionReference} for that parent's MockItemSubItemDeep subcollection.
|
|
1626
1677
|
*/ function mockItemSubItemDeepCollectionReferenceFactory(context) {
|
|
1627
1678
|
return function(parent) {
|
|
1628
1679
|
return context.subcollection(parent.documentRef, mockItemSubItemDeepIdentity.collectionName);
|
|
@@ -1630,6 +1681,9 @@ var mockItemUserIdentifier = '0';
|
|
|
1630
1681
|
}
|
|
1631
1682
|
/**
|
|
1632
1683
|
* Creates a factory for producing {@link MockItemSubItemDeepFirestoreCollection} instances bound to a parent {@link MockItemSubItemDocument}.
|
|
1684
|
+
*
|
|
1685
|
+
* @param firestoreContext - The Firestore context used to resolve the underlying subcollection.
|
|
1686
|
+
* @returns A factory that, given a parent {@link MockItemSubItemDocument}, returns a per-parent collection wired with {@link mockItemSubItemDeepConverter}.
|
|
1633
1687
|
*/ function mockItemSubItemDeepFirestoreCollection(firestoreContext) {
|
|
1634
1688
|
var factory = mockItemSubItemDeepCollectionReferenceFactory(firestoreContext);
|
|
1635
1689
|
return function(parent) {
|
|
@@ -1647,11 +1701,17 @@ var mockItemUserIdentifier = '0';
|
|
|
1647
1701
|
}
|
|
1648
1702
|
/**
|
|
1649
1703
|
* Creates a {@link CollectionGroup} reference for querying all {@link MockItemSubItemDeep} documents across parents.
|
|
1704
|
+
*
|
|
1705
|
+
* @param context - The Firestore context used to resolve the collection group.
|
|
1706
|
+
* @returns A typed {@link CollectionGroup} reference for the MockItemSubItemDeep collection name.
|
|
1650
1707
|
*/ function mockItemSubItemDeepCollectionReference(context) {
|
|
1651
1708
|
return context.collectionGroup(mockItemSubItemDeepIdentity.collectionName);
|
|
1652
1709
|
}
|
|
1653
1710
|
/**
|
|
1654
1711
|
* Creates a {@link MockItemSubItemDeepFirestoreCollectionGroup} for cross-parent queries on {@link MockItemSubItemDeep}.
|
|
1712
|
+
*
|
|
1713
|
+
* @param firestoreContext - The Firestore context used to resolve the underlying collection group reference.
|
|
1714
|
+
* @returns A typed {@link MockItemSubItemDeepFirestoreCollectionGroup} wired with the {@link mockItemSubItemDeepConverter}.
|
|
1655
1715
|
*/ function mockItemSubItemDeepFirestoreCollectionGroup(firestoreContext) {
|
|
1656
1716
|
return firestoreContext.firestoreCollectionGroup({
|
|
1657
1717
|
modelIdentity: mockItemSubItemDeepIdentity,
|
|
@@ -1706,6 +1766,9 @@ function _class_call_check$4(instance, Constructor) {
|
|
|
1706
1766
|
* Creates a concrete {@link MockItemCollections} instance with all collections bound to the given {@link FirestoreContext}.
|
|
1707
1767
|
*
|
|
1708
1768
|
* This is the primary way to instantiate the full set of mock collections for a test run.
|
|
1769
|
+
*
|
|
1770
|
+
* @param firestoreContext - The Firestore context (typically a {@link TestFirestoreContext}) that backs every collection.
|
|
1771
|
+
* @returns A fully populated {@link MockItemCollections} with each mock collection, factory, and collection group wired to `firestoreContext`.
|
|
1709
1772
|
*/ function makeMockItemCollections(firestoreContext) {
|
|
1710
1773
|
return {
|
|
1711
1774
|
mockItemCollection: mockItemFirestoreCollection(firestoreContext),
|
|
@@ -1931,6 +1994,9 @@ function _is_native_reflect_construct$3() {
|
|
|
1931
1994
|
{
|
|
1932
1995
|
key: "firestoreCollection",
|
|
1933
1996
|
get: /**
|
|
1997
|
+
* Backwards-compatible alias for {@link MockItemCollectionFixtureInstance.mockItemCollection}.
|
|
1998
|
+
*
|
|
1999
|
+
* @returns The root {@link MockItemFirestoreCollection} from the fixture's underlying {@link MockItemCollections}.
|
|
1934
2000
|
* @deprecated Use mockItemCollection instead.
|
|
1935
2001
|
*/ function get() {
|
|
1936
2002
|
return this.collections.mockItemCollection;
|
|
@@ -2019,6 +2085,9 @@ function _is_native_reflect_construct$3() {
|
|
|
2019
2085
|
* it('should work', () => { ... });
|
|
2020
2086
|
* }));
|
|
2021
2087
|
* ```
|
|
2088
|
+
*
|
|
2089
|
+
* @param _config - Reserved for future setup/teardown configuration; currently unused.
|
|
2090
|
+
* @returns A factory builder that wraps a parent {@link TestFirestoreContextFixture} with a {@link MockItemCollectionFixture} per test.
|
|
2022
2091
|
*/ function testWithMockItemCollectionFixture(_config) {
|
|
2023
2092
|
return test.instanceWrapTestContextFactory({
|
|
2024
2093
|
wrapFixture: function wrapFixture(fixture) {
|
|
@@ -2185,6 +2254,9 @@ function _is_native_reflect_construct$2() {
|
|
|
2185
2254
|
* it('should upload', () => { ... });
|
|
2186
2255
|
* }));
|
|
2187
2256
|
* ```
|
|
2257
|
+
*
|
|
2258
|
+
* @param _config - Reserved for future setup/teardown configuration; currently unused.
|
|
2259
|
+
* @returns A factory builder that wraps a parent {@link TestFirebaseStorageContextFixture} with a {@link MockItemStorageFixture} per test.
|
|
2188
2260
|
*/ function testWithMockItemStorageFixture(_config) {
|
|
2189
2261
|
return test.instanceWrapTestContextFactory({
|
|
2190
2262
|
wrapFixture: function wrapFixture(fixture) {
|
|
@@ -2357,11 +2429,17 @@ function _is_native_reflect_construct$1() {
|
|
|
2357
2429
|
* const constraint = mockItemWithValue('hello');
|
|
2358
2430
|
* const results = await collection.query(constraint);
|
|
2359
2431
|
* ```
|
|
2432
|
+
*
|
|
2433
|
+
* @param value - The exact `value` to match.
|
|
2434
|
+
* @returns A `where('value', '==', value)` constraint typed for {@link MockItem}.
|
|
2360
2435
|
*/ function mockItemWithValue(value) {
|
|
2361
2436
|
return firebase.where('value', '==', value);
|
|
2362
2437
|
}
|
|
2363
2438
|
/**
|
|
2364
2439
|
* Creates a Firestore query constraint that filters {@link MockItem} documents by their `test` boolean field.
|
|
2440
|
+
*
|
|
2441
|
+
* @param test - The boolean value of the `test` field to match.
|
|
2442
|
+
* @returns A `where('test', '==', test)` constraint.
|
|
2365
2443
|
*/ function mockItemWithTestValue(test) {
|
|
2366
2444
|
return firebase.where('test', '==', test);
|
|
2367
2445
|
}
|
|
@@ -2379,8 +2457,8 @@ function _is_native_reflect_construct$1() {
|
|
|
2379
2457
|
* From:
|
|
2380
2458
|
* https://medium.com/firebase-developers/how-to-query-collections-in-firestore-under-a-certain-path-6a0d686cebd2
|
|
2381
2459
|
*
|
|
2382
|
-
* @param parent
|
|
2383
|
-
* @returns
|
|
2460
|
+
* @param mockItem - The parent {@link MockItem} document reference whose descendant documents the constraint should bound to.
|
|
2461
|
+
* @returns An array of constraints (suitable for use on a collection group query) that restricts results to documents under the given parent path.
|
|
2384
2462
|
*/ function allChildMockItemSubItemDeepsWithinMockItem(mockItem) {
|
|
2385
2463
|
return firebase.allChildDocumentsUnderParent(mockItem);
|
|
2386
2464
|
}
|
|
@@ -5058,6 +5136,27 @@ function _ts_generator$3(thisArg, body) {
|
|
|
5058
5136
|
};
|
|
5059
5137
|
}
|
|
5060
5138
|
}
|
|
5139
|
+
/**
|
|
5140
|
+
* Creates a gate that calls `done()` once both `setSeen()` and `setCompleted()` have been invoked.
|
|
5141
|
+
*
|
|
5142
|
+
* Used to coordinate streamed-emission and post-mutation callbacks in stream-update tests.
|
|
5143
|
+
*
|
|
5144
|
+
* @param done - The Vitest async-test completion callback to invoke once both sides of the gate have fired.
|
|
5145
|
+
* @returns A two-method gate; the test calls `setSeen()` from the stream subscription and `setCompleted()` from the mutation continuation, and `done()` runs only after both have happened (in either order).
|
|
5146
|
+
*/ function makeAwaitBothGate(done) {
|
|
5147
|
+
var seen = false;
|
|
5148
|
+
var completed = false;
|
|
5149
|
+
return {
|
|
5150
|
+
setSeen: function setSeen() {
|
|
5151
|
+
seen = true;
|
|
5152
|
+
if (completed) done();
|
|
5153
|
+
},
|
|
5154
|
+
setCompleted: function setCompleted() {
|
|
5155
|
+
completed = true;
|
|
5156
|
+
if (seen) done();
|
|
5157
|
+
}
|
|
5158
|
+
};
|
|
5159
|
+
}
|
|
5061
5160
|
/**
|
|
5062
5161
|
* Describes query driver tests, using a MockItemCollectionFixture.
|
|
5063
5162
|
*
|
|
@@ -6196,20 +6295,13 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6196
6295
|
sub.destroy();
|
|
6197
6296
|
});
|
|
6198
6297
|
it('should emit when the query results update (an item is added).', test.callbackTest(function(done) {
|
|
6199
|
-
var tryComplete = function tryComplete() {
|
|
6200
|
-
if (addSeen && addCompleted) {
|
|
6201
|
-
done();
|
|
6202
|
-
}
|
|
6203
|
-
};
|
|
6204
6298
|
var itemsToAdd = 1;
|
|
6205
|
-
var
|
|
6206
|
-
var addSeen = false;
|
|
6299
|
+
var gate = makeAwaitBothGate(done);
|
|
6207
6300
|
sub.subscription = querySubItems().streamDocs().pipe(rxjs$1.filter(function(x) {
|
|
6208
6301
|
return x.docs.length > allSubItems.length;
|
|
6209
6302
|
})).subscribe(function(results) {
|
|
6210
|
-
addSeen = true;
|
|
6211
6303
|
expect(results.docs.length).toBe(allSubItems.length + itemsToAdd);
|
|
6212
|
-
|
|
6304
|
+
gate.setSeen();
|
|
6213
6305
|
});
|
|
6214
6306
|
// add one item
|
|
6215
6307
|
void firebase.makeDocuments(f.instance.mockItemSubItemCollection(parentA).documentAccessor(), {
|
|
@@ -6220,32 +6312,23 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6220
6312
|
};
|
|
6221
6313
|
}
|
|
6222
6314
|
}).then(function() {
|
|
6223
|
-
|
|
6224
|
-
tryComplete();
|
|
6315
|
+
gate.setCompleted();
|
|
6225
6316
|
});
|
|
6226
6317
|
}));
|
|
6227
6318
|
it('should emit when the query results update (an item is removed).', test.callbackTest(function(done) {
|
|
6228
|
-
var tryComplete = function tryComplete() {
|
|
6229
|
-
if (deleteSeen && deleteCompleted) {
|
|
6230
|
-
done();
|
|
6231
|
-
}
|
|
6232
|
-
};
|
|
6233
6319
|
var itemsToRemove = 1;
|
|
6234
|
-
var
|
|
6235
|
-
var deleteSeen = false;
|
|
6320
|
+
var gate = makeAwaitBothGate(done);
|
|
6236
6321
|
sub.subscription = querySubItems().streamDocs().pipe(rxjs$1.filter(function(x) {
|
|
6237
6322
|
return x.docs.length < allSubItems.length;
|
|
6238
6323
|
})).subscribe(function(results) {
|
|
6239
|
-
deleteSeen = true;
|
|
6240
6324
|
expect(results.docs.length).toBe(allSubItems.length - itemsToRemove);
|
|
6241
|
-
|
|
6325
|
+
gate.setSeen();
|
|
6242
6326
|
});
|
|
6243
6327
|
void allSubItems[0].accessor.exists().then(function(exists) {
|
|
6244
6328
|
expect(exists).toBe(true);
|
|
6245
6329
|
// remove one item
|
|
6246
6330
|
return allSubItems[0].accessor.delete().then(function() {
|
|
6247
|
-
|
|
6248
|
-
tryComplete();
|
|
6331
|
+
gate.setCompleted();
|
|
6249
6332
|
});
|
|
6250
6333
|
});
|
|
6251
6334
|
}));
|
|
@@ -6444,20 +6527,13 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6444
6527
|
sub.destroy();
|
|
6445
6528
|
});
|
|
6446
6529
|
it('should emit when the query results update (an item is added).', test.callbackTest(function(done) {
|
|
6447
|
-
var tryComplete = function tryComplete() {
|
|
6448
|
-
if (addSeen && addCompleted) {
|
|
6449
|
-
done();
|
|
6450
|
-
}
|
|
6451
|
-
};
|
|
6452
6530
|
var itemsToAdd = 1;
|
|
6453
|
-
var
|
|
6454
|
-
var addSeen = false;
|
|
6531
|
+
var gate = makeAwaitBothGate(done);
|
|
6455
6532
|
sub.subscription = queryDocument().streamDocs().pipe(rxjs$1.filter(function(documents) {
|
|
6456
6533
|
return documents.length > items.length;
|
|
6457
6534
|
})).subscribe(function(documents) {
|
|
6458
|
-
addSeen = true;
|
|
6459
6535
|
expect(documents.length).toBe(items.length + itemsToAdd);
|
|
6460
|
-
|
|
6536
|
+
gate.setSeen();
|
|
6461
6537
|
});
|
|
6462
6538
|
// add one item
|
|
6463
6539
|
void util.waitForMs(10).then(function() {
|
|
@@ -6470,32 +6546,23 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6470
6546
|
};
|
|
6471
6547
|
}
|
|
6472
6548
|
}).then(function() {
|
|
6473
|
-
|
|
6474
|
-
tryComplete();
|
|
6549
|
+
gate.setCompleted();
|
|
6475
6550
|
});
|
|
6476
6551
|
});
|
|
6477
6552
|
}));
|
|
6478
6553
|
it('should emit when the query results update (an item is removed).', test.callbackTest(function(done) {
|
|
6479
|
-
var tryComplete = function tryComplete() {
|
|
6480
|
-
if (deleteSeen && deleteCompleted) {
|
|
6481
|
-
done();
|
|
6482
|
-
}
|
|
6483
|
-
};
|
|
6484
6554
|
var itemsToRemove = 1;
|
|
6485
|
-
var
|
|
6486
|
-
var deleteSeen = false;
|
|
6555
|
+
var gate = makeAwaitBothGate(done);
|
|
6487
6556
|
sub.subscription = queryDocument().streamDocs().pipe(rxjs$1.skip(1)).subscribe(function(documents) {
|
|
6488
|
-
deleteSeen = true;
|
|
6489
6557
|
expect(documents.length).toBe(items.length - itemsToRemove);
|
|
6490
|
-
|
|
6558
|
+
gate.setSeen();
|
|
6491
6559
|
});
|
|
6492
6560
|
void util.waitForMs(10).then(function() {
|
|
6493
6561
|
return items[0].exists().then(function(exists) {
|
|
6494
6562
|
expect(exists).toBe(true);
|
|
6495
6563
|
// remove one item
|
|
6496
6564
|
return items[0].accessor.delete().then(function() {
|
|
6497
|
-
|
|
6498
|
-
tryComplete();
|
|
6565
|
+
gate.setCompleted();
|
|
6499
6566
|
});
|
|
6500
6567
|
});
|
|
6501
6568
|
});
|
|
@@ -6510,18 +6577,11 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6510
6577
|
sub.destroy();
|
|
6511
6578
|
});
|
|
6512
6579
|
it('should emit when the query results update (an item is added).', test.callbackTest(function(done) {
|
|
6513
|
-
var tryComplete = function tryComplete() {
|
|
6514
|
-
if (addSeen && addCompleted) {
|
|
6515
|
-
done();
|
|
6516
|
-
}
|
|
6517
|
-
};
|
|
6518
6580
|
var itemsToAdd = 1;
|
|
6519
|
-
var
|
|
6520
|
-
var addSeen = false;
|
|
6581
|
+
var gate = makeAwaitBothGate(done);
|
|
6521
6582
|
sub.subscription = queryDocument().streamDocSnapshotDataPairs().pipe(rxjs$1.filter(function(documents) {
|
|
6522
6583
|
return documents.length > items.length;
|
|
6523
6584
|
})).subscribe(function(documents) {
|
|
6524
|
-
addSeen = true;
|
|
6525
6585
|
expect(documents.length).toBe(items.length + itemsToAdd);
|
|
6526
6586
|
documents.forEach(function(x) {
|
|
6527
6587
|
// validate each document returned
|
|
@@ -6533,7 +6593,7 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6533
6593
|
expect(x.snapshot.ref).toBeDefined();
|
|
6534
6594
|
expect(x.snapshot.id).toBe(x.document.id);
|
|
6535
6595
|
});
|
|
6536
|
-
|
|
6596
|
+
gate.setSeen();
|
|
6537
6597
|
});
|
|
6538
6598
|
// add one item
|
|
6539
6599
|
void util.waitForMs(10).then(function() {
|
|
@@ -6546,32 +6606,23 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6546
6606
|
};
|
|
6547
6607
|
}
|
|
6548
6608
|
}).then(function() {
|
|
6549
|
-
|
|
6550
|
-
tryComplete();
|
|
6609
|
+
gate.setCompleted();
|
|
6551
6610
|
});
|
|
6552
6611
|
});
|
|
6553
6612
|
}));
|
|
6554
6613
|
it('should emit when the query results update (an item is removed).', test.callbackTest(function(done) {
|
|
6555
|
-
var tryComplete = function tryComplete() {
|
|
6556
|
-
if (deleteSeen && deleteCompleted) {
|
|
6557
|
-
done();
|
|
6558
|
-
}
|
|
6559
|
-
};
|
|
6560
6614
|
var itemsToRemove = 1;
|
|
6561
|
-
var
|
|
6562
|
-
var deleteSeen = false;
|
|
6615
|
+
var gate = makeAwaitBothGate(done);
|
|
6563
6616
|
sub.subscription = queryDocument().streamDocs().pipe(rxjs$1.skip(1)).subscribe(function(documents) {
|
|
6564
|
-
deleteSeen = true;
|
|
6565
6617
|
expect(documents.length).toBe(items.length - itemsToRemove);
|
|
6566
|
-
|
|
6618
|
+
gate.setSeen();
|
|
6567
6619
|
});
|
|
6568
6620
|
void util.waitForMs(10).then(function() {
|
|
6569
6621
|
return items[0].exists().then(function(exists) {
|
|
6570
6622
|
expect(exists).toBe(true);
|
|
6571
6623
|
// remove one item
|
|
6572
6624
|
return items[0].accessor.delete().then(function() {
|
|
6573
|
-
|
|
6574
|
-
tryComplete();
|
|
6625
|
+
gate.setCompleted();
|
|
6575
6626
|
});
|
|
6576
6627
|
});
|
|
6577
6628
|
});
|
|
@@ -6599,20 +6650,13 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6599
6650
|
sub.destroy();
|
|
6600
6651
|
});
|
|
6601
6652
|
it('should emit when the query results update (an item is added).', test.callbackTest(function(done) {
|
|
6602
|
-
var tryComplete = function tryComplete() {
|
|
6603
|
-
if (addSeen && addCompleted) {
|
|
6604
|
-
done();
|
|
6605
|
-
}
|
|
6606
|
-
};
|
|
6607
6653
|
var itemsToAdd = 1;
|
|
6608
|
-
var
|
|
6609
|
-
var addSeen = false;
|
|
6654
|
+
var gate = makeAwaitBothGate(done);
|
|
6610
6655
|
sub.subscription = query().streamDocs().pipe(rxjs$1.filter(function(x) {
|
|
6611
6656
|
return x.docs.length > items.length;
|
|
6612
6657
|
})).subscribe(function(results) {
|
|
6613
|
-
addSeen = true;
|
|
6614
6658
|
expect(results.docs.length).toBe(items.length + itemsToAdd);
|
|
6615
|
-
|
|
6659
|
+
gate.setSeen();
|
|
6616
6660
|
});
|
|
6617
6661
|
// add one item
|
|
6618
6662
|
void util.waitForMs(10).then(function() {
|
|
@@ -6625,32 +6669,23 @@ function _ts_generator$3(thisArg, body) {
|
|
|
6625
6669
|
};
|
|
6626
6670
|
}
|
|
6627
6671
|
}).then(function() {
|
|
6628
|
-
|
|
6629
|
-
tryComplete();
|
|
6672
|
+
gate.setCompleted();
|
|
6630
6673
|
});
|
|
6631
6674
|
});
|
|
6632
6675
|
}));
|
|
6633
6676
|
it('should emit when the query results update (an item is removed).', test.callbackTest(function(done) {
|
|
6634
|
-
var tryComplete = function tryComplete() {
|
|
6635
|
-
if (deleteSeen && deleteCompleted) {
|
|
6636
|
-
done();
|
|
6637
|
-
}
|
|
6638
|
-
};
|
|
6639
6677
|
var itemsToRemove = 1;
|
|
6640
|
-
var
|
|
6641
|
-
var deleteSeen = false;
|
|
6678
|
+
var gate = makeAwaitBothGate(done);
|
|
6642
6679
|
sub.subscription = query().streamDocs().pipe(rxjs$1.skip(1)).subscribe(function(results) {
|
|
6643
|
-
deleteSeen = true;
|
|
6644
6680
|
expect(results.docs.length).toBe(items.length - itemsToRemove);
|
|
6645
|
-
|
|
6681
|
+
gate.setSeen();
|
|
6646
6682
|
});
|
|
6647
6683
|
void util.waitForMs(10).then(function() {
|
|
6648
6684
|
return items[0].accessor.exists().then(function(exists) {
|
|
6649
6685
|
expect(exists).toBe(true);
|
|
6650
6686
|
// remove one item
|
|
6651
6687
|
return items[0].accessor.delete().then(function() {
|
|
6652
|
-
|
|
6653
|
-
tryComplete();
|
|
6688
|
+
gate.setCompleted();
|
|
6654
6689
|
});
|
|
6655
6690
|
});
|
|
6656
6691
|
});
|