()
| 50 | let dbWithDataCreated = false; |
| 51 | |
| 52 | export async function openDBWithData() { |
| 53 | if (dbWithDataCreated) return openDB<TestDBSchema>(dbName, version); |
| 54 | dbWithDataCreated = true; |
| 55 | const db = await openDBWithSchema(); |
| 56 | const tx = db.transaction(['key-val-store', 'object-store'], 'readwrite'); |
| 57 | const keyStore = tx.objectStore('key-val-store'); |
| 58 | const objStore = tx.objectStore('object-store'); |
| 59 | keyStore.put(123, 'foo'); |
| 60 | keyStore.put(456, 'bar'); |
| 61 | keyStore.put(789, 'hello'); |
| 62 | objStore.put({ |
| 63 | id: 1, |
| 64 | title: 'Article 1', |
| 65 | date: new Date('2019-01-04'), |
| 66 | }); |
| 67 | objStore.put({ |
| 68 | id: 2, |
| 69 | title: 'Article 2', |
| 70 | date: new Date('2019-01-03'), |
| 71 | }); |
| 72 | objStore.put({ |
| 73 | id: 3, |
| 74 | title: 'Article 3', |
| 75 | date: new Date('2019-01-02'), |
| 76 | }); |
| 77 | objStore.put({ |
| 78 | id: 4, |
| 79 | title: 'Article 4', |
| 80 | date: new Date('2019-01-01'), |
| 81 | }); |
| 82 | return db; |
| 83 | } |
| 84 | |
| 85 | export function deleteDatabase(callbacks: DeleteDBCallbacks = {}) { |
| 86 | version = 0; |
no test coverage detected
searching dependent graphs…