Skip to content

Commit 3dadeb1

Browse files
docs(README.md): update.
1 parent 9d7cfcc commit 3dadeb1

1 file changed

Lines changed: 67 additions & 28 deletions

File tree

README.md

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Jasmine unit testing wrapper with additional custom testing features.
4343
* [Usage](#usage)
4444
* [Features](#features)
4545
* [Expectations](#expectations)
46+
* [Nested](#nested-expectations)
47+
* [Standalone](#standalone-expectations)
4648
* [It](#it)
4749
* [Nested](#nested)
4850
* [Standalone](#standalone)
@@ -110,31 +112,28 @@ npm i --save @angular-package/testing
110112
* Main.
111113
*/
112114
export {
113-
// Class.
114-
Testing,
115-
TestingActual,
116-
117-
// Class to handle `describe`, `it`, `expect` of jasmine.
118-
TestingCore,
115+
Testing, // Main class with all testings.
116+
TestingActual, // Initialize testing for `actual`.
117+
TestingCustom, // Class to pass custom testings.
119118

120-
// Class to customize testing.
121-
TestingCustom,
119+
// Full named expectations. Methods with `expect()` + jasmine matchers.
120+
TestingExpectation,
122121

123122
// Class to handle `describe()` function of jasmine.
124123
TestingDescribe,
125124

125+
// Class to handle `it()` function of jasmine.
126+
TestingIt,
127+
126128
// Class to handle `expect()` function of jasmine.
127129
TestingExpect,
128130

131+
// Class to handle `describe`, `it`, `expect` of jasmine.
132+
TestingCore,
133+
129134
// Abstract class to handle executable tests.
130135
TestingExecutable,
131-
132-
// Full named expectations. Methods with `expect()` + jasmine matchers.
133-
TestingExpectation,
134-
135-
// Class to handle `it()` function of jasmine.
136-
TestingIt,
137-
} from '@angular-package/testing';
136+
} from './lib';
138137

139138
// Specific expectations.
140139
export {
@@ -146,21 +145,22 @@ export {
146145
TestingExpectToHaveBeen,
147146
TestingExpectToHaveBeenCalled,
148147
TestingExpectToThrow,
149-
} from '@angular-package/testing';
148+
} from './lib/expectation';
150149

151150
// Methods with `it()` function of jasmine.
152151
export {
153152
TestingItTo,
154153
TestingItToBe,
155154
TestingItToBeArrayOf,
155+
TestingItToBeBoolean,
156156
TestingItToBeInstanceOf,
157157
TestingItToHave,
158158
TestingItToHaveBeen,
159159
TestingItToHaveBeenCalled,
160160
TestingItToThrow,
161-
} from '@angular-package/testing';
161+
} from './lib/it';
162162

163-
// Testing for customization.
163+
// Testing classes for use with `TestingCustom`.
164164
export {
165165
TestingTo,
166166
TestingToBe,
@@ -174,7 +174,7 @@ export {
174174
TestingToBeString,
175175
TestingToHave,
176176
TestingToThrow,
177-
} from '@angular-package/testing';
177+
} from './lib/testing';
178178
```
179179

180180
```typescript
@@ -261,7 +261,13 @@ import { Testing } from "@angular-package/testing";
261261
Use `TestingCustom` class for custom testing.
262262

263263
```typescript
264-
import { TestingDescribe, TestingCustom, TestingIt, TestingToBe } from "@angular-package/testing";
264+
import {
265+
TestingCustom,
266+
TestingDescribe,
267+
TestingExpectation,
268+
TestingIt,
269+
TestingToBe,
270+
} from "@angular-package/testing";
265271

266272
const t = new TestingCustom(
267273
[TestingToBe], // List of test.
@@ -271,8 +277,9 @@ const t = new TestingCustom(
271277
['DescribeA'], // Descriptions for `describe`.
272278
['ItA'], // Expectations for `it`.
273279
[false, false], // `boolean` or list of [`boolean`, `boolean`]
274-
new TestingDescribe(), // Instance for `TestingDescribe` for `counter` purposes
275-
new TestingIt() // Instance for `TestingIt` for `counter` purposes
280+
new TestingDescribe(), // Common instance for `TestingDescribe` for `counter` purposes
281+
new TestingIt(), // Common instance for `TestingIt` for `counter` purposes
282+
new TestingExpectation() // Common instance for `TestingExpectation`
276283
);
277284
```
278285

@@ -285,12 +292,19 @@ const t = new TestingCustom(
285292
Expectation is a method built from `expect()` and `jasmine` matcher.
286293

287294
```typescript
288-
expect(expect).matcher(expected)
295+
public expectation(actual, expected) {
296+
expect(actual).matcher(expected);
297+
return this;
298+
}
289299
```
290300

291-
```typescript
292-
import { TestingExpectation } from "@angular-package/testing";
293-
```
301+
### Nested expectations
302+
303+
Expectation methods are accessed by using nested object structure and method names.
304+
305+
### Standalone expectations
306+
307+
Expectation methods are directly accessed by using method names instead of nested structure, but using it through the `TestingExpectTo`.
294308

295309
Jasmine matchers in use.
296310

@@ -405,6 +419,31 @@ Expectations based on the `are` of `@angular-package/type` and `toBe()` matcher
405419
- [x] `toBeArrayOfTrue()`
406420
- [x] `toBeArrayOfUndefined()`
407421

422+
Example
423+
424+
```typescript
425+
import { Testing, TestingExpectation } from "@angular-package/testing";
426+
427+
const t = new Testing();
428+
const to = new TestingExpectation();
429+
430+
t.describe(`TestingExpectation`, () => t
431+
.spec(e => e.toBeArrayOfNull([null, null]))
432+
.it(`it`, () => to
433+
.toContain(['a', 'b', 'c'], 'c')
434+
.toContain('string number', 'ber')
435+
.toEqual({a: 2}, {a: 2})
436+
.toMatch("my string", /string$/)
437+
.toMatch('number', 'ber')
438+
439+
.not.toContain(['a', 'b', 'c'], 'h')
440+
.toContain(['a', 'b', 'c'], 'a')
441+
442+
.not.toBeBigInt('a')
443+
)
444+
);
445+
```
446+
408447
### It
409448

410449
Prepared specs `it` of `jasmine` built. Spec is a method built from `it` with expectation - `expect()` and `jasmine` matcher.
@@ -415,7 +454,7 @@ it(description, () => expect(expect).matcher(expected))
415454

416455
### Nested
417456

418-
`it` methods accessed by using nested object structure and method names.
457+
`it` methods are accessed by using nested object structure and method names.
419458

420459
### `TestingItTo`
421460

@@ -827,7 +866,7 @@ Method
827866

828867
### Standalone
829868

830-
`it` methods directly accessed by using method names instead of nested structure, but using it.
869+
`it` methods are directly accessed by using method names instead of nested structure, but using it.
831870
Standalone tests are designed to mixin them in `TestingCustom` class.
832871

833872
### `TestingToBeArrayOf`

0 commit comments

Comments
 (0)