Skip to content

Commit 8777cab

Browse files
committed
chore: readme updated
1 parent 871f3dd commit 8777cab

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
### Realar Jest example
22

3+
Example of easy unit testing with [Realar](https://github.com/betula/realar).
4+
5+
```javascript
6+
import { mock } from "realar";
7+
import { Notifier, Api, UserForm } from "./user-form";
8+
9+
test("User form should work", async () => {
10+
const notifierMock = mock(Notifier, {
11+
fail: jest.fn()
12+
});
13+
const apiMock = mock(Api, {
14+
userSave: jest.fn().mockResolvedValue(0)
15+
});
16+
17+
const form = new UserForm("a", "b");
18+
19+
await form.save();
20+
expect(notifierMock.fail).toHaveBeenCalled();
21+
expect(apiMock.userSave).toHaveBeenCalledWith("a", "b");
22+
});
23+
```
24+
325
Installation
426

527
```bash

0 commit comments

Comments
 (0)