(newId: string)
| 18 | }) |
| 19 | |
| 20 | async function createItem(newId: string) { |
| 21 | const itemsStream = getShapeStream<Item>(itemShape()) |
| 22 | |
| 23 | // Match the insert |
| 24 | const findUpdatePromise = matchStream({ |
| 25 | stream: itemsStream, |
| 26 | operations: [`insert`], |
| 27 | matchFn: ({ message }) => message.value.id === newId, |
| 28 | }) |
| 29 | |
| 30 | // Insert item |
| 31 | const fetchPromise = fetch(itemsUrl, { |
| 32 | method: `POST`, |
| 33 | body: JSON.stringify({ id: newId }), |
| 34 | }) |
| 35 | |
| 36 | return await Promise.all([findUpdatePromise, fetchPromise]) |
| 37 | } |
| 38 | |
| 39 | async function clearItems(numItems: number) { |
| 40 | const itemsStream = getShapeStream(itemShape()) |
no test coverage detected