(
noteStoreFactory: (
wsRoot: string,
vaults: DVault[],
engine: DEngineClient
) => Promise<INoteStore<string>>
)
| 340 | } |
| 341 | |
| 342 | function getDeletedNoteTest( |
| 343 | noteStoreFactory: ( |
| 344 | wsRoot: string, |
| 345 | vaults: DVault[], |
| 346 | engine: DEngineClient |
| 347 | ) => Promise<INoteStore<string>> |
| 348 | ) { |
| 349 | test("WHEN writing and deleting a note, THEN get should return CONTENT_NOT_FOUND", async () => { |
| 350 | await runEngineTestV5( |
| 351 | async ({ vaults, wsRoot, engine }) => { |
| 352 | const vault = vaults[0]; |
| 353 | |
| 354 | const noteStore = await noteStoreFactory(wsRoot, vaults, engine); |
| 355 | const newNote = await NoteTestUtilsV4.createNote({ |
| 356 | fname: "foobar", |
| 357 | body: "note body", |
| 358 | vault, |
| 359 | wsRoot, |
| 360 | }); |
| 361 | |
| 362 | await noteStore.write({ key: newNote.id, note: newNote }); |
| 363 | |
| 364 | // Test NoteStore.get |
| 365 | const note = await noteStore.get(newNote.id); |
| 366 | expect(note.data!.fname).toEqual(newNote.fname); |
| 367 | |
| 368 | // Test NoteStore.queryMetadata |
| 369 | let queryResp = await noteStore.queryMetadata({ |
| 370 | qs: "foobar", |
| 371 | originalQS: "foobar", |
| 372 | }); |
| 373 | expect(queryResp.isOk()).toBeTruthy(); |
| 374 | queryResp.map((results) => { |
| 375 | expect(results.length).toEqual(1); |
| 376 | expect(results[0].fname).toEqual("foobar"); |
| 377 | }); |
| 378 | |
| 379 | // Test NoteStore.delete |
| 380 | const deleteResp = await noteStore.delete(newNote.id); |
| 381 | expect(deleteResp.data).toBeTruthy(); |
| 382 | |
| 383 | const note2 = await noteStore.get(newNote.id); |
| 384 | expect(note2.error?.status).toEqual(ERROR_STATUS.CONTENT_NOT_FOUND); |
| 385 | |
| 386 | queryResp = await noteStore.queryMetadata({ |
| 387 | qs: "foobar", |
| 388 | originalQS: "foobar", |
| 389 | }); |
| 390 | expect(queryResp.isOk()).toBeTruthy(); |
| 391 | queryResp.map((results) => { |
| 392 | expect(results.length).toEqual(0); |
| 393 | }); |
| 394 | }, |
| 395 | { |
| 396 | expect, |
| 397 | } |
| 398 | ); |
| 399 | }); |
no test coverage detected