(
initialDocs: Array<TestDocType> = [],
dbId = dbNameId++,
)
| 36 | } |
| 37 | |
| 38 | async function getDatababase( |
| 39 | initialDocs: Array<TestDocType> = [], |
| 40 | dbId = dbNameId++, |
| 41 | ) { |
| 42 | const db = await createRxDatabase<RxCollections, unknown, unknown, unknown>( |
| 43 | { |
| 44 | name: `my-rxdb-` + dbId, |
| 45 | ignoreDuplicate: true, |
| 46 | storage: wrappedValidateAjvStorage({ |
| 47 | storage: getRxStorageMemory(), |
| 48 | }), |
| 49 | }, |
| 50 | ) |
| 51 | const collections = await db.addCollections<RxCollections>({ |
| 52 | test: { |
| 53 | schema: { |
| 54 | version: 0, |
| 55 | type: `object`, |
| 56 | primaryKey: `id`, |
| 57 | properties: { |
| 58 | id: { |
| 59 | type: `string`, |
| 60 | maxLength: 100, |
| 61 | }, |
| 62 | name: { |
| 63 | type: `string`, |
| 64 | maxLength: 9, |
| 65 | }, |
| 66 | }, |
| 67 | }, |
| 68 | }, |
| 69 | }) |
| 70 | const rxCollection: RxCollection<TestDocType> = collections.test |
| 71 | if (initialDocs.length > 0) { |
| 72 | const insertResult = await rxCollection.bulkInsert(initialDocs) |
| 73 | expect(insertResult.error.length).toBe(0) |
| 74 | } |
| 75 | return db |
| 76 | } |
| 77 | |
| 78 | async function createTestState( |
| 79 | initialDocs: Array<TestDocType> = [], |
no test coverage detected