Skip to content

Commit

Permalink
📝 add informations about mock system
Browse files Browse the repository at this point in the history
  • Loading branch information
FBerthelot committed Mar 20, 2019
1 parent e7a3569 commit c4eaa36
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion website/docs/shallow/constructor.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,32 @@ The option object is a way to passing property or some other informations to bui

Here is the list of available options:

- {Object} `props` The key is the property name, and the value his value.
- {Object} `mocks` The key is the property name, and the value his value.

### Examples

#### react

```jsx
const ChildComponent = ({nbLikes}) => {
return <button type="button">{nbLikes}</button>;
};

const Component = () => {
return (
<section id="post">
<ChildComponent nbLikes={0} />
</section>
);
};

const cmp = shallow(<Component />, {
mock: {
ChildComponent
}
});

expect(cmp.html()).toBe(
'<section id="post"><ChildComponent nbLikes="0"><button type="button">0</button></ChildComponent></section>'
);
```

0 comments on commit c4eaa36

Please sign in to comment.