mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 12:49:10 +00:00
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:
parent
305a9c04ba
commit
ae86cbb551
16 changed files with 60 additions and 60 deletions
|
@ -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)}`;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue