rename(std/testing): rename assert*Contains to assert*Includes (#7951)

This commit renames two assertion functions to better align with JS API:
- assertStringContains -> assertStringIncludes
- assertArrayContains -> assertArrayIncludes
This commit is contained in:
Tim Reichen 2020-10-26 16:03:30 +01:00 committed by GitHub
parent 305a9c04ba
commit ae86cbb551
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 60 additions and 60 deletions

View file

@ -330,10 +330,10 @@ export function assertNotStrictEquals(
}
/**
* Make an assertion that actual contains expected. If not
* Make an assertion that actual includes expected. If not
* then thrown.
*/
export function assertStringContains(
export function assertStringIncludes(
actual: string,
expected: string,
msg?: string,
@ -347,26 +347,26 @@ export function assertStringContains(
}
/**
* Make an assertion that `actual` contains the `expected` values.
* Make an assertion that `actual` includes the `expected` values.
* If not then an error will be thrown.
*
* Type parameter can be specified to ensure values under comparison have the same type.
* For example:
*```ts
*assertArrayContains<number>([1, 2], [2])
*assertArrayIncludes<number>([1, 2], [2])
*```
*/
export function assertArrayContains(
export function assertArrayIncludes(
actual: ArrayLike<unknown>,
expected: ArrayLike<unknown>,
msg?: string,
): void;
export function assertArrayContains<T>(
export function assertArrayIncludes<T>(
actual: ArrayLike<T>,
expected: ArrayLike<T>,
msg?: string,
): void;
export function assertArrayContains(
export function assertArrayIncludes(
actual: ArrayLike<unknown>,
expected: ArrayLike<unknown>,
msg?: string,
@ -388,7 +388,7 @@ export function assertArrayContains(
return;
}
if (!msg) {
msg = `actual: "${_format(actual)}" expected to contain: "${
msg = `actual: "${_format(actual)}" expected to include: "${
_format(expected)
}"\nmissing: ${_format(missing)}`;
}