@@ -12,125 +12,6 @@ Additional matchers for [Jest](https://jestjs.io) making it easier to test `Eith
1212yarn add @pacote/jest-either
1313```
1414
15- ## Usage
16-
17- ``` typescript
18- import matchers from ' @pacote/jest-either'
19-
20- expect .extend (matchers )
21- ```
22-
23- ### ` .toBeEither() `
24-
25- ``` typescript
26- import { left , right } from ' fp-ts/lib/Either'
27-
28- test (' passes when value is an Either' , () => {
29- expect (left (true )).toBeEither ()
30- expect (right (true )).toBeEither ()
31- })
32-
33- test (' passes when value is not an Either' , () => {
34- expect (undefined ).not .toBeEither ()
35- })
36- ```
37-
38- ### ` .toBeRight() `
39-
40- ``` typescript
41- import { left , right } from ' fp-ts/lib/Either'
42-
43- test (' passes when Either is a right' , () => {
44- const actual = right ({ test: ' ok' })
45- expect (actual ).toBeRight ()
46- })
47-
48- test (' passes when Either is a left' , () => {
49- const actual = left (Error ())
50- expect (actual ).not .toBeRight ()
51- })
52- ```
53-
54- ### ` .toBeLeft() `
55-
56- ``` typescript
57- import { left , right } from ' fp-ts/lib/Either'
58-
59- test (' passes when Either is a left' , () => {
60- const actual = left (Error ())
61- expect (actual ).toBeLeft ()
62- })
63-
64- test (' passes when Either is a right' , () => {
65- const actual = right ({ test: ' ok' })
66- expect (actual ).not .toBeLeft ()
67- })
68- ```
69-
70- ### ` .toEqualRight(value) `
71-
72- ``` typescript
73- import { right } from ' fp-ts/lib/Either'
74-
75- test (' passes when right of Either equals a value' , () => {
76- const actual = right ({ test: ' ok' })
77- expect (actual ).toEqualRight ({ test: ' ok' })
78- })
79-
80- test (' passes when right of Either does not equal a value' , () => {
81- const actual = right ({ test: ' unexpected' })
82- expect (actual ).not .toEqualRight ({ test: ' ok' })
83- })
84- ```
85-
86- ### ` .toEqualLeft(value) `
87-
88- ``` typescript
89- import { left } from ' fp-ts/lib/Either'
90-
91- test (' passes when left of Either equals a value' , () => {
92- const actual = left (Error (' message' ))
93- expect (actual ).toEqualLeft (Error (' message' ))
94- })
95-
96- test (' passes when left of Either does not equal a value' , () => {
97- const actual = left (Error (' unexpected' ))
98- expect (actual ).not .toEqualLeft (Error (' message' ))
99- })
100- ```
101-
102- ### ` .toMatchRight(object) `
103-
104- ``` typescript
105- import { right } from ' fp-ts/lib/Either'
106-
107- test (' passes when right of Either matches an object' , () => {
108- const actual = right ({ test: ' ok' , foo: ' bar' })
109- expect (actual ).toMatchRight ({ test: ' ok' })
110- })
111-
112- test (' passes when right of Either does not match an object' , () => {
113- const actual = right ({ test: ' unexpected' , foo: ' bar' })
114- expect (actual ).not .toMatchRight ({ test: ' ok' })
115- })
116- ```
117-
118- ### ` .toMatchLeft(object) `
119-
120- ``` typescript
121- import { left } from ' fp-ts/lib/Either'
122-
123- test (' passes when left of Either matches an object' , () => {
124- const actual = left ({ test: ' ok' , foo: ' bar' })
125- expect (actual ).toMatchLeft ({ test: ' ok' })
126- })
127-
128- test (' passes when left of Either does not match an object' , () => {
129- const actual = left ({ test: ' unexpected' , foo: ' bar' })
130- expect (actual ).not .toMatchLeft ({ test: ' ok' })
131- })
132- ```
133-
13415## License
13516
13617MIT © [ Luís Rodrigues] ( https://goblindegook.com ) .
0 commit comments