MCPcopy
hub / github.com/jestjs/jest / expectCommonItems

Function expectCommonItems

packages/diff-sequences/src/__tests__/index.test.ts:239–252  ·  view source on GitHub ↗
(
  a: Array<unknown> | string,
  b: Array<unknown> | string,
  expected: Array<unknown>,
)

Source from the content-addressed store, hash-verified

237
238// Assert that array-like objects have the expected common items.
239const expectCommonItems = (
240 a: Array<unknown> | string,
241 b: Array<unknown> | string,
242 expected: Array<unknown>,
243) => {
244 expect(findCommonItems(a, b)).toEqual(expected);
245
246 if (a.length !== b.length) {
247 // If sequences a and b have different lengths,
248 // then if you swap sequences in your callback functions,
249 // this package finds the same items.
250 expect(findCommonItems(b, a)).toEqual(expected);
251 }
252};
253
254describe('input callback encapsulates sequences', () => {
255 // Example sequences in “edit graph” analogy from

Callers 1

index.test.tsFile · 0.85

Calls 3

expectFunction · 0.85
toEqualMethod · 0.80
findCommonItemsFunction · 0.70

Tested by

no test coverage detected