Skip to content

Commit 4138fff

Browse files
docs(README.md): update
1 parent f9bb739 commit 4138fff

1 file changed

Lines changed: 178 additions & 27 deletions

File tree

README.md

Lines changed: 178 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -152,36 +152,36 @@ Simple object to support the testing.
152152

153153
**Instance methods:**
154154

155-
| Testing.prototype. | Description |
156-
| :-------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ |
155+
| Testing.prototype. | Description |
156+
| :-------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------ |
157157
| [`describe()`](#testingprototypedescribe) | Executes defined `describe()` function of jasmine on a state `true` from the `execute` |
158158
| [`it()`](#testingprototypeit) | Executes defined `it()` function of jasmine on a state `true` from the `execute` |
159159
| [`toBe()`](#testingprototypetobe) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be the given `expected` value |
160-
| [`toBeBigInt()`](#testingprototypetobebigint) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be a `bigint` type on the given `toBe` state of `true` |
161-
| [`toBeBooleanType()`](#testingprototypetobebooleantype) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be of a `boolean` type on the given `toBe` state of `true` |
162-
| [`toBeClass()`](#testingprototypetobeclass) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be a `class` on the given `toBe` state of `true` |
163-
| [`toBeInstanceOfArray()`](#testingprototypetobeinstanceofarray) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of an [`Array`][js-array] on the given `toBe` state of `true` |
164-
| [`toBeInstanceOfBoolean()`](#testingprototypetobeinstanceofboolean) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Boolean`][js-boolean] on the given `toBe` state of `true` |
165-
| [`toBeInstanceOfDate()`](#testingprototypetobeinstanceofdate) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Date`][js-date] on the given `toBe` state of `true` |
166-
| [`toBeInstanceOfError()`](#testingprototypetobeinstanceoferror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of an [`Error`][js-error] on the given `toBe` state of `true` |
167-
| [`toBeInstanceOfFunction()`](#testingprototypetobeinstanceoffunction) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`Function`][js-function] on the given `toBe` state of `true` |
168-
| [`toBeInstanceOfMap()`](#testingprototypetobeinstanceofmap) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`Map`][js-map] on the given `toBe` state of `true` |
169-
| [`toBeInstanceOfNumber()`](#testingprototypetobeinstanceofnumber) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`Number`][js-number] on the given `toBe` state of `true` |
170-
| [`toBeInstanceOfObject()`](#testingprototypetobeinstanceofobject) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of an [`Object`][js-object] on the given `toBe` state of `true` |
171-
| [`toBeInstanceOfPromise()`](#testingprototypetobeinstanceofpromise) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Promise`][js-promise] on the given `toBe` state of `true` |
172-
| [`toBeInstanceOfRangeError()`](#testingprototypetobeinstanceofrangeerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`RangeError`][js-rangeerror] on the given `toBe` state of `true` |
173-
| [`toBeInstanceOfReferenceError()`](#testingprototypetobeinstanceofreferenceerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`ReferenceError`][js-referenceerror] on the given `toBe` state of `true` |
174-
| [`toBeInstanceOfRegExp()`](#testingprototypetobeinstanceofregexp) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`RegExp`][js-regexp] on the given `toBe` state of `true` |
175-
| [`toBeInstanceOfSet()`](#testingprototypetobeinstanceofset) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Set`][js-set] on the given `toBe` state of `true` |
176-
| [`toBeInstanceOfStorage()`](#testingprototypetobeinstanceofstorage) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Storage`][js-storage] on the given `toBe` state of `true` |
177-
| [`toBeInstanceOfString()`](#testingprototypetobeinstanceofstring) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`String`][js-string] on the given `toBe` state of `true` |
178-
| [`toBeInstanceOfSyntaxError()`](#testingprototypetobeinstanceofsyntaxerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`SyntaxError`][js-syntaxerror] on the given `toBe` state of `true` |
179-
| [`toBeInstanceOfTypeError()`](#testingprototypetobeinstanceoftypeerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`TypeError`][js-typeerror] on the given `toBe` state of `true` |
180-
| [`toBeInstanceOfURIError()`](#testingprototypetobeinstanceofurlerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`URIError`][js-urlerror] on the given `toBe` state of `true` |
181-
| [`toBeInstanceOfWeakSet()`](#testingprototypetobeinstanceofweakset) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`WeakSet`][js-weakset] on the given `toBe` state of `true` |
182-
| [`toBeNull()`](#testingprototypetobenull) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be [`null`][js-null] on the given `toBe` state of `true` |
183-
| [`toBeNumberType()`](#testingprototypetobenumbertype) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be of a [`number`][js-number] type on the given `toBe` state of `true` |
184-
| [`toBeStringType()`](#testingprototypetobestringtype) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be of a [`string`][js-string] type on the given `toBe` state of `true` |
160+
| [`toBeBigInt()`](#testingprototypetobebigint) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be a `bigint` type on the given `expected` state of `true` |
161+
| [`toBeBooleanType()`](#testingprototypetobebooleantype) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be of a `boolean` type on the given `expected` state of `true` |
162+
| [`toBeClass()`](#testingprototypetobeclass) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be a `class` on the given `expected` state of `true` |
163+
| [`toBeInstanceOfArray()`](#testingprototypetobeinstanceofarray) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of an [`Array`][js-array] on the given `expected` state of `true` |
164+
| [`toBeInstanceOfBoolean()`](#testingprototypetobeinstanceofboolean) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Boolean`][js-boolean] on the given `expected` state of `true` |
165+
| [`toBeInstanceOfDate()`](#testingprototypetobeinstanceofdate) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Date`][js-date] on the given `expected` state of `true` |
166+
| [`toBeInstanceOfError()`](#testingprototypetobeinstanceoferror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of an [`Error`][js-error] on the given `expected` state of `true` |
167+
| [`toBeInstanceOfFunction()`](#testingprototypetobeinstanceoffunction) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`Function`][js-function] on the given `expected` state of `true` |
168+
| [`toBeInstanceOfMap()`](#testingprototypetobeinstanceofmap) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`Map`][js-map] on the given `expected` state of `true` |
169+
| [`toBeInstanceOfNumber()`](#testingprototypetobeinstanceofnumber) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`Number`][js-number] on the given `expected` state of `true` |
170+
| [`toBeInstanceOfObject()`](#testingprototypetobeinstanceofobject) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of an [`Object`][js-object] on the given `expected` state of `true` |
171+
| [`toBeInstanceOfPromise()`](#testingprototypetobeinstanceofpromise) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Promise`][js-promise] on the given `expected` state of `true` |
172+
| [`toBeInstanceOfRangeError()`](#testingprototypetobeinstanceofrangeerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`RangeError`][js-rangeerror] on the given `expected` state of `true` |
173+
| [`toBeInstanceOfReferenceError()`](#testingprototypetobeinstanceofreferenceerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`ReferenceError`][js-referenceerror] on the given `expected` state of `true` |
174+
| [`toBeInstanceOfRegExp()`](#testingprototypetobeinstanceofregexp) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`RegExp`][js-regexp] on the given `expected` state of `true` |
175+
| [`toBeInstanceOfSet()`](#testingprototypetobeinstanceofset) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Set`][js-set] on the given `expected` state of `true` |
176+
| [`toBeInstanceOfStorage()`](#testingprototypetobeinstanceofstorage) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`Storage`][js-storage] on the given `expected` state of `true` |
177+
| [`toBeInstanceOfString()`](#testingprototypetobeinstanceofstring) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`String`][js-string] on the given `expected` state of `true` |
178+
| [`toBeInstanceOfSyntaxError()`](#testingprototypetobeinstanceofsyntaxerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`SyntaxError`][js-syntaxerror] on the given `expected` state of `true` |
179+
| [`toBeInstanceOfTypeError()`](#testingprototypetobeinstanceoftypeerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`TypeError`][js-typeerror] on the given `expected` state of `true` |
180+
| [`toBeInstanceOfURIError()`](#testingprototypetobeinstanceofurlerror) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of [`URIError`][js-urlerror] on the given `expected` state of `true` |
181+
| [`toBeInstanceOfWeakSet()`](#testingprototypetobeinstanceofweakset) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be an instance of a [`WeakSet`][js-weakset] on the given `expected` state of `true` |
182+
| [`toBeNull()`](#testingprototypetobenull) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be [`null`][js-null] on the given `expected` state of `true` |
183+
| [`toBeNumberType()`](#testingprototypetobenumbertype) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be of a [`number`][js-number] type on the given `expected` state of `true` |
184+
| [`toBeStringType()`](#testingprototypetobestringtype) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to be of a [`string`][js-string] type on the given `expected` state of `true` |
185185
| [`toEqual()`](#testingprototypetoequal) | Executes the spec on a state `true` from the `execute` expecting the provided `value` to equal to the given `expected` |
186186

187187
<br>
@@ -231,6 +231,58 @@ const testing = new Testing(
231231
);
232232
```
233233

234+
Examples of using allow.
235+
236+
```typescript
237+
/**
238+
* Initialize testing.
239+
*/
240+
const testing = new Testing(
241+
false, // Disallows executing the `describe()` method globally.
242+
false, // Disallows executing the `it()` method globally.
243+
{
244+
describe: [1, 2, 3, 5], // Executable unique numbers of `describe()` methods to execute when globally is disallowed.
245+
it: [1], // Executable unique numbers of `it()` methods inside the `describe()` to execute when globally is disallowed.
246+
}
247+
);
248+
249+
testing.describe('[counter] First describe', () => {
250+
testing
251+
.it('[counter] First it() in first describe 1-1', () =>
252+
expect(false).toBeFalse()
253+
)
254+
.it('[counter] Second it() in first describe 1-2', () =>
255+
expect(true).toBeTrue()
256+
)
257+
.it('[counter] Second it() in first describe 1-3', () =>
258+
expect(true).toBeTrue()
259+
)
260+
.it('[counter] Fourth it() in first describe() 1-4', () =>
261+
expect(true).toBeTrue()
262+
)
263+
.describe('[counter] Second describe()', () => {
264+
testing.it('[counter] First it() in second describe() 2-1', () =>
265+
expect(true).toBeTrue()
266+
);
267+
})
268+
.describe('[counter] Third describe()', () => {
269+
testing.it('[counter] First it() in third describe() 3-1', () =>
270+
expect(true).toBeTrue()
271+
);
272+
})
273+
.describe('[counter] Fourth describe()', () => {
274+
testing.it('[counter] First it() in fourth describe() 3-1', () =>
275+
expect(true).toBeTrue()
276+
);
277+
});
278+
});
279+
testing.describe('[counter] Fifth describe', () =>
280+
testing.it('[counter] First it() in fifth describe 5-1', () =>
281+
expect(false).toBeFalse()
282+
)
283+
);
284+
```
285+
234286
<br>
235287

236288
### `Testing` static methods
@@ -343,10 +395,109 @@ testing.describe('defineIt()', () => {
343395

344396
### `Testing.prototype.describe()`
345397

398+
Executes defined [`describe()`][jasmine-describe] function of jasmine on provided state `true` from the `execute`, and resets the counter to `0`.
399+
400+
```typescript
401+
public describe(
402+
description: string,
403+
specDefinitions: () => void,
404+
execute?: boolean
405+
): this {
406+
this.#testingIt.resetCounter();
407+
this.#testingDescribe.describe(description, specDefinitions, execute);
408+
return this;
409+
}
410+
```
411+
412+
**Parameters:**
413+
414+
| Name: type | Description |
415+
| :---------------------------- | :---------- |
416+
| `description: string` | "Textual description of the group" with an optional defined prefix indicating its unique number inside the describe |
417+
| `specDefinitions: () => void` | "Function for Jasmine to invoke that will define inner suites a specs" |
418+
| `execute: boolean` | A [`boolean`][js-boolean] type value to decide whether or not execute defined [`describe()`][jasmine-describe] of jasmine function |
419+
420+
**Returns:**
421+
422+
The **return value** is an instance of a child class, which in this case is [`Testing`](#testing).
423+
424+
**Usage:**
425+
426+
```typescript
427+
// Example usage.
428+
// Object.
429+
import { is } from '@angular-package/type';
430+
// Class.
431+
import { Testing } from '@angular-package/testing';
432+
/**
433+
* Initialize testing.
434+
*/
435+
const testing = new Testing(true, true);
436+
/**
437+
* describe().
438+
*/
439+
testing.describe(
440+
'[counter] describe()',
441+
() => {},
442+
true // Whether or not execute suite
443+
);
444+
```
445+
346446
<br>
347447

348448
### `Testing.prototype.it()`
349449

450+
Executes defined [`it()`][jasmine-it] function of jasmine on provided state `true` from the `execute`.
451+
452+
```typescript
453+
public it(
454+
expectation: string,
455+
assertion: jasmine.ImplementationCallback,
456+
execute?: boolean
457+
): this {
458+
this.#testingIt.it(expectation, assertion, execute);
459+
return this;
460+
}
461+
```
462+
463+
**Parameters:**
464+
465+
| Name: type | Description |
466+
| :---------------------------- | :---------- |
467+
| `description: string` | "Textual description of what this spec is checking" with an optional its unique number when adding `[counter]` |
468+
| `specDefinitions: () => void` | "Function that contains the code of your test. If not provided the test will be pending." |
469+
| `execute: boolean` | A [`boolean`][js-boolean] type value to decide whether or not execute defined [`it()`][jasmine-it] of jasmine function |
470+
471+
**Returns:**
472+
473+
The **return value** is an instance of a child class, which in this case is [`Testing`](#testing).
474+
475+
**Usage:**
476+
477+
```typescript
478+
// Example usage.
479+
// Object.
480+
import { is } from '@angular-package/type';
481+
// Class.
482+
import { Testing } from '@angular-package/testing';
483+
/**
484+
* Initialize testing.
485+
*/
486+
const testing = new Testing(true, true);
487+
/**
488+
* it().
489+
*/
490+
testing.describe(
491+
'[counter] describe()',
492+
() => testing.it('[counter] it()', () => {
493+
expect(true).toBeTruthy();
494+
},
495+
true // Whether or not execute spec
496+
),
497+
true // Whether or not execute suite
498+
);
499+
```
500+
350501
<br>
351502

352503
### `Testing.prototype.toBe()`

0 commit comments

Comments
 (0)