( collection: Collection<T>, expectedIds: Array<string>, message?: string, )
| 37 | * Assert that a collection has loaded at least the expected items (may have more) |
| 38 | */ |
| 39 | export function assertLoadedAtLeast<T extends { id: string }>( |
| 40 | collection: Collection<T>, |
| 41 | expectedIds: Array<string>, |
| 42 | message?: string, |
| 43 | ) { |
| 44 | const loadedIds = getLoadedIds(collection) |
| 45 | const loadedSet = new Set(loadedIds) |
| 46 | |
| 47 | const missingIds = expectedIds.filter((id) => !loadedSet.has(id)) |
| 48 | if (missingIds.length > 0) { |
| 49 | throw new Error( |
| 50 | message ?? |
| 51 | `Collection is missing items: ${missingIds.join(`, `)} (loaded: ${loadedIds.join(`, `)})`, |
| 52 | ) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Assert that a collection has NOT loaded any of the specified items |
nothing calls this directly
no test coverage detected
searching dependent graphs…