expectUnorderedItems()function

expectUnorderedItems(items: Iterable<Item<I, T>>, keys: Iterable<string> & NotString): void
ParamType
itemsIterable<Item<I, T>>
The items to check, each carrying an .id prop. required
keysIterable<string> & NotString
The exact set of .id values expected (order ignored). required
Throws
Error
If the items' ids don't match keys.

Assert that a set of Item objects has exactly the expected .id values, in any order.

  • Sorts both sides before comparing, so iteration order is ignored.
  • On failure, rewrites the stack trace to point at the call site.

Examples

expectUnorderedItems(results, ["person1", "person2"])