MCPcopy Create free account
hub / github.com/TanStack/db / createTestState

Function createTestState

packages/rxdb-db-collection/tests/rxdb.test.ts:78–103  ·  view source on GitHub ↗
(
    initialDocs: Array<TestDocType> = [],
    config: Partial<RxDBCollectionConfig<TestDocType, any>> = {},
  )

Source from the content-addressed store, hash-verified

76 }
77
78 async function createTestState(
79 initialDocs: Array<TestDocType> = [],
80 config: Partial<RxDBCollectionConfig<TestDocType, any>> = {},
81 ) {
82 const db = await getDatababase(initialDocs, dbNameId++)
83 const rxCollection: RxCollection<TestDocType> = db.test
84 const options = rxdbCollectionOptions({
85 rxCollection: rxCollection,
86 startSync: true,
87 /**
88 * In tests we use a small batch size
89 * to ensure iteration works.
90 */
91 syncBatchSize: 10,
92 ...config,
93 })
94
95 const collection = createCollection(options)
96 await collection.stateWhenReady()
97
98 return {
99 collection,
100 rxCollection,
101 db,
102 }
103 }
104
105 describe(`sync`, () => {
106 it(`should initialize and fetch initial data`, async () => {

Callers 1

rxdb.test.tsFile · 0.85

Calls 4

rxdbCollectionOptionsFunction · 0.90
createCollectionFunction · 0.90
getDatababaseFunction · 0.85
stateWhenReadyMethod · 0.80

Tested by

no test coverage detected