Skip to content

Commit 38f8bf0

Browse files
docs(README.md): update.
1 parent 1c85a4f commit 38f8bf0

1 file changed

Lines changed: 102 additions & 38 deletions

File tree

README.md

Lines changed: 102 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
| [reactive][reactive-github-readme] | Automatize the process of creating some rxjs features. | [![npm version][reactive-npm-badge-png]][reactive-npm-badge] |
1616
| [storage][storage-github-readme] | The storage of data under allowed names. | [![npm version][storage-npm-badge-png]][storage-npm-badge] |
1717
| [tag][tag-github-readme] | Any tag with optional attributes. | [![npm version][tag-npm-badge-png]][tag-npm-badge] |
18-
| [testing][testing-github-readme] | Support for testing other packages. | [![npm version][testing-npm-badge-png]][testing-npm-badge] |
18+
| **[testing][testing-github-readme]** | **Support for testing other packages.** | [![npm version][testing-npm-badge-png]][testing-npm-badge] |
1919
| [text][text-github-readme] | Text on the template with replaceable tags. | [![npm version][text-npm-badge-png]][text-npm-badge] |
20-
| **[type][type-github-readme]** | **Common types, type guards, and type checkers.** | [![npm version][type-npm-badge-png]][type-npm-badge] |
20+
| [type][type-github-readme] | Common types, type guards, and type checkers. | [![npm version][type-npm-badge-png]][type-npm-badge] |
2121
| [ui][ui-github-readme] | User interface. | *In Progress* |
2222
| [wrapper][wrapper-github-readme] | Wrap the text with the opening and closing chars. | [![npm version][wrapper-npm-badge-png]][wrapper-npm-badge] |
2323

@@ -1983,35 +1983,36 @@ Matchers that use the `toBe()` method of [`jasmine.Matchers`][jasmine-matchers].
19831983

19841984
**Instance public methods:**
19851985

1986-
| TestingToBeMatchers.prototype. | Expects provided `value` to be |
1987-
| :------------------------------------------------------------------------ | :----------------------------- |
1988-
| [`array()`](#testingtobematchersprototypearray) | an [`array`][js-array]. |
1989-
| [`bigint()`](#testingtobematchersprototypebigint) | a [`bigint`][js-bigint] type. |
1990-
| [`boolean()`](#testingtobematchersprototypeboolean) | a [`boolean`][js-boolean] type or an instance of [`Boolean`][js-boolean]. |
1991-
| [`class()`](#testingtobematchersprototypeclass) | a [`class`][js-classes]. |
1992-
| [`date()`](#testingtobematchersprototypedate) | a [`Date`][js-date]. |
1993-
| [`defined()`](#testingtobematchersprototypedefined) | **defined**. |
1994-
| [`false()`](#testingtobematchersprototypefalse) | a [`boolean`][js-boolean] type or an instance of [`Boolean`][js-boolean] equal to `false`. |
1995-
| [`function()`](#testingtobematchersprototypefunction) | [`function`][js-function]. |
1996-
| [`instance()`](#testingtobematchersprototypeinstance) | an instance of a [`class`][js-classes] from the given `constructor`. |
1997-
| [`key()`](#testingtobematchersprototypekey) | a property key. |
1998-
| [`null()`](#testingtobematchersprototypenull) | [`null`][js-null]. |
1999-
| [`number()`](#testingtobematchersprototypenumber) | a [`number`][js-number] type or an instance of a [`Number`][js-number]. |
2000-
| [`numberBetween()`](#testingtobematchersprototypenumberbetween) | a [`number`][js-number] type or an instance of a [`Number`][js-number] between the **range** of **minimum** and **maximum**. |
2001-
| [`object()`](#testingtobematchersprototypeobject) | an [`object`][js-object]. |
2002-
| [`objectKey()`](#testingtobematchersprototypeobjectkey) | an [`object`][js-object] with a given `key` by using the [`hasOwnProperty()`][js-hasownproperty] method of the [`Object`][js-object]. |
2003-
| [`objectKeyIn()`](#testingtobematchersprototypeobjectkeyin) | an [`object`][js-object] with a given `key` in it(or its prototype chain) by using the [`in`][js-in-operator] operator. |
2004-
| [`objectKeys()`](#testingtobematchersprototypeobjectkeys) | an [`object`][js-object] with given `keys` by using the [`hasOwnProperty()`][js-hasownproperty] method of the [`Object`][js-object]. |
2005-
| [`objectKeysIn()`](#testingtobematchersprototypeobjectkeysin) | an [`object`][js-object] with given `keys` in it(or its prototype chain) by using the [`in`][js-in-operator] operator. |
2006-
| [`objectSomeKeys()`](#testingtobematchersprototypeobjectsomekeys) | an [`object`][js-object] with **some** of its keys or **some groups** of its keys of the `PropertyKey` type. |
2007-
| [`regexp()`](#testingtobematchersprototyperegexp) | [`RegExp`][js-regexp]. |
2008-
| [`string()`](#testingtobematchersprototypestring) | a [`string`][js-string] type or an instance of a [`String`][js-string]. |
2009-
| [`stringIncludes()`](#testingtobematchersprototypestringincludes) | a [`string`][js-string] type or an instance of a [`String`][js-string] that **includes** the specified **words/sentences**. |
2010-
| [`stringIncludesSome()`](#testingtobematchersprototypestringincludessome) | a [`string`][js-string] type or an instance of a [`String`][js-string] that **includes some** of the specified **words/sentences**. |
2011-
| [`stringOfLength()`](#testingtobematchersprototypestringoflength) | a [`string`][js-string] type or an instance of a [`String`][js-string] of the **length** between the given **minimum** and **maximum**. |
2012-
| [`symbol()`](#testingtobematchersprototypesymbol) | a [`symbol`][js-symbol]. |
2013-
| [`true()`](#testingtobematchersprototypetrue) | a [`boolean`][js-boolean] type or an instance of [`Boolean`][js-boolean] equal to `true`. |
2014-
| [`undefined()`](#testingtobematchersprototypeundefined) | [`undefined`][js-undefined]. |
1986+
| TestingToBeMatchers.prototype. | Expects provided `value` to be |
1987+
| :------------------------------------------------------------------------------ | :----------------------------- |
1988+
| [`array()`](#testingtobematchersprototypearray) | an [`array`][js-array]. |
1989+
| [`bigint()`](#testingtobematchersprototypebigint) | a [`bigint`][js-bigint] type. |
1990+
| [`boolean()`](#testingtobematchersprototypeboolean) | a [`boolean`][js-boolean] type or an instance of [`Boolean`][js-boolean]. |
1991+
| [`class()`](#testingtobematchersprototypeclass) | a [`class`][js-classes]. |
1992+
| [`date()`](#testingtobematchersprototypedate) | a [`Date`][js-date]. |
1993+
| [`defined()`](#testingtobematchersprototypedefined) | **defined**. |
1994+
| [`false()`](#testingtobematchersprototypefalse) | a [`boolean`][js-boolean] type or an instance of [`Boolean`][js-boolean] equal to `false`. |
1995+
| [`function()`](#testingtobematchersprototypefunction) | [`function`][js-function]. |
1996+
| [`instance()`](#testingtobematchersprototypeinstance) | an instance of a [`class`][js-classes] from the given `constructor`. |
1997+
| [`key()`](#testingtobematchersprototypekey) | a property key. |
1998+
| [`null()`](#testingtobematchersprototypenull) | [`null`][js-null]. |
1999+
| [`number()`](#testingtobematchersprototypenumber) | a [`number`][js-number] type or an instance of a [`Number`][js-number]. |
2000+
| [`numberBetween()`](#testingtobematchersprototypenumberbetween) | a [`number`][js-number] type or an instance of a [`Number`][js-number] between the **range** of **minimum** and **maximum**. |
2001+
| [`object()`](#testingtobematchersprototypeobject) | an [`object`][js-object]. |
2002+
| [`objectKey()`](#testingtobematchersprototypeobjectkey) | an [`object`][js-object] with a given `key` by using the [`hasOwnProperty()`][js-hasownproperty] method of the [`Object`][js-object]. |
2003+
| [`objectKeyIn()`](#testingtobematchersprototypeobjectkeyin) | an [`object`][js-object] with a given `key` in it(or its prototype chain) by using the [`in`][js-in-operator] operator. |
2004+
| [`objectKeys()`](#testingtobematchersprototypeobjectkeys) | an [`object`][js-object] with given `keys` by using the [`hasOwnProperty()`][js-hasownproperty] method of the [`Object`][js-object]. |
2005+
| [`objectKeysIn()`](#testingtobematchersprototypeobjectkeysin) | an [`object`][js-object] with given `keys` in it(or its prototype chain) by using the [`in`][js-in-operator] operator. |
2006+
| [`objectSomeKeys()`](#testingtobematchersprototypeobjectsomekeys) | an [`object`][js-object] with **some** of its keys or **some groups** of its keys of the `PropertyKey` type. |
2007+
| [`regexp()`](#testingtobematchersprototyperegexp) | [`RegExp`][js-regexp]. |
2008+
| [`string()`](#testingtobematchersprototypestring) | a [`string`][js-string] type or an instance of a [`String`][js-string]. |
2009+
| [`stringIncludes()`](#testingtobematchersprototypestringincludes) | a [`string`][js-string] type or an instance of a [`String`][js-string] that **includes** the specified **words/sentences**. |
2010+
| [`stringIncludesSome()`](#testingtobematchersprototypestringincludessome) | a [`string`][js-string] type or an instance of a [`String`][js-string] that **includes some** of the specified **words/sentences**. |
2011+
| [`stringOfLength()`](#testingtobematchersprototypestringoflength) | a [`string`][js-string] type or an instance of a [`String`][js-string] of the specified **length**. |
2012+
| [`stringOfLengthBetween()`](#testingtobematchersprototypestringoflengthbetween) | a [`string`][js-string] type or an instance of a [`String`][js-string] of the **length** between the given **minimum** and **maximum**. |
2013+
| [`symbol()`](#testingtobematchersprototypesymbol) | a [`symbol`][js-symbol]. |
2014+
| [`true()`](#testingtobematchersprototypetrue) | a [`boolean`][js-boolean] type or an instance of [`Boolean`][js-boolean] equal to `true`. |
2015+
| [`undefined()`](#testingtobematchersprototypeundefined) | [`undefined`][js-undefined]. |
20152016

20162017
<br>
20172018

@@ -3357,10 +3358,73 @@ testing.describe('Expects provided value', () => {
33573358

33583359
[![update]][testing-github-changelog]
33593360

3360-
Expects provided `value` to be a [`string`][js-string] type or an instance of a [`String`][js-string] of the **length** between the given **minimum** and **maximum**. The method uses [`isStringLength()`](https://github.com/angular-package/type#isstringlength) function from the [`@angular-package/type`][type-github-readme].
3361+
Expects provided `value` to be a [`string`][js-string] type or an instance of a [`String`][js-string] of the given **length**. The method uses [`isStringLength()`](https://docs.angular-package.dev/v/type/is/isstringlength) function from the [`@angular-package/type`][type-github-readme].
33613362

33623363
```typescript
3363-
public stringOfLength<Min extends number, Max extends number>(
3364+
public stringOfLength<Length extends number>(
3365+
value: any,
3366+
length: Length,
3367+
expected: jasmine.Expected<boolean> = true,
3368+
expectationFailOutput: any = `${this.expectationFailOutput} ${
3369+
this.getNot() === true ? `not` : ``
3370+
} be a \`string\` type or an instance of a \`String\` of the specified \`length\` equal to ${length}`
3371+
): this {
3372+
this.toBe(is.stringLength(value, length), expected, expectationFailOutput);
3373+
return this;
3374+
}
3375+
```
3376+
3377+
**Parameters:**
3378+
3379+
| Name: type | Description |
3380+
| :------------------------------------ | :---------- |
3381+
| `value: any` | The `value` of any type that is checked against a [`string`][js-string] type or an instance of a [`String`][js-string] of the given **length** and the result of its check is passed to the [`expect()`][jasmine-expect] function of jasmine. |
3382+
| `length: Length` | The **length** of generic type variable `Length` for the given `value`, |
3383+
| `expected: jasmine.Expected<boolean>` | The expected value of a [`boolean`][js-boolean] to compare against the result of the `value` check that is passed to the `toBe()` method of [`jasmine.Matchers`][jasmine-matchers]. |
3384+
| `expectationFailOutput: any` | An additional message when the matcher fails, by default, states the `value` should be (or not) a [`string`][js-string] type or an instance of a [`String`][js-string] of the specified **length**. |
3385+
3386+
**Returns:**
3387+
3388+
The **return value** is an instance of a [`TestingToBeMatchers`](#testingtobematchers).
3389+
3390+
**Usage:**
3391+
3392+
```typescript
3393+
// Example usage.
3394+
import { Testing, TestingToBeMatchers } from '@angular-package/testing';
3395+
/**
3396+
* Create `Testing` instance.
3397+
*/
3398+
const testing = new Testing(true, true);
3399+
const toBe = new TestingToBeMatchers();
3400+
/**
3401+
* Tests.
3402+
*/
3403+
testing.describe('Expects provided value', () => {
3404+
let string: any;
3405+
let length: any;
3406+
beforeEach(() => {
3407+
string = 'My new string, My new string';
3408+
length = 28;
3409+
});
3410+
testing.describe('to be or not to be', () => {
3411+
testing.it(`a \`string\` of the given length`, () =>
3412+
toBe.stringOfLength(string, length).
3413+
not.stringOfLength(undefined, length-10));
3414+
});
3415+
});
3416+
```
3417+
3418+
<br>
3419+
3420+
#### `TestingToBeMatchers.prototype.stringOfLengthBetween()`
3421+
3422+
[![new]][testing-github-changelog]
3423+
3424+
Expects provided `value` to be a [`string`][js-string] type or an instance of a [`String`][js-string] of the **length** between the given **minimum** and **maximum**. The method uses [`isStringLengthBetween()`](https://docs.angular-package.dev/v/type/is/isstringlengthbetween) function from the [`@angular-package/type`][type-github-readme].
3425+
3426+
```typescript
3427+
public stringOfLengthBetween<Min extends number, Max extends number>(
33643428
value: any,
33653429
min: Min,
33663430
max: Max,
@@ -3370,7 +3434,7 @@ public stringOfLength<Min extends number, Max extends number>(
33703434
} be a \`string\` type or an instance of a \`String\` of the \`length\` between the given ${min} and ${max}`
33713435
): this {
33723436
this.toBe(
3373-
is.stringLength(value, min, max),
3437+
is.stringLengthBetween(value, min, max),
33743438
expected,
33753439
expectationFailOutput
33763440
);
@@ -3382,7 +3446,7 @@ public stringOfLength<Min extends number, Max extends number>(
33823446

33833447
| Name: type | Description |
33843448
| :------------------------------------ | :---------- |
3385-
| `value: any` | The `value` of any type that is checked against a [`string`][js-string] type or an instance of a [`String`][js-string] of the specified **length** and the result of its check is passed to the [`expect()`][jasmine-expect] function of jasmine. |
3449+
| `value: any` | The `value` of any type that is checked against a [`string`][js-string] type or an instance of a [`String`][js-string] of the specified **min** and **max** and the result of its check is passed to the [`expect()`][jasmine-expect] function of jasmine. |
33863450
| `min: Min` | The **minimum** length of generic type variable `Min` of a given `value`. |
33873451
| `max: Max` | The **maximum** length of generic type variable `Max` of a given `value`. |
33883452
| `expected: jasmine.Expected<boolean>` | The expected value of a [`boolean`][js-boolean] to compare against the result of the `value` check that is passed to the `toBe()` method of [`jasmine.Matchers`][jasmine-matchers]. |
@@ -3415,9 +3479,9 @@ testing.describe('Expects provided value', () => {
34153479
max = 28;
34163480
});
34173481
testing.describe('to be or not to be', () => {
3418-
testing.it(`a \`string\` between the given length`, () =>
3419-
toBe.stringOfLength(string, min, max).
3420-
not.stringOfLength(undefined, min, max));
3482+
testing.it(`a \`string\` between the given min and max.`, () =>
3483+
toBe.stringOfLengthBetween(string, min, max).
3484+
not.stringOfLengthBetween(undefined, min, max));
34213485
});
34223486
});
34233487
```

0 commit comments

Comments
 (0)