Skip to content

Commit

Permalink
[Docs] clean up linting errors in root export docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 17, 2017
1 parent c1e8c2f commit c2cb3a3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 36 deletions.
14 changes: 6 additions & 8 deletions docs/api/mount.md
Expand Up @@ -5,7 +5,7 @@ or may require the full lifecycle in order to fully test the component (i.e., `c
etc.)

Full DOM rendering requires that a full DOM API be available at the global scope. This means that
it must be run in an environment that at least "looks like" a browser environment. If you do not
it must be run in an environment that at least looks like a browser environment. If you do not
want to run your tests inside of a browser, the recommended approach to using `mount` is to depend
on a library called [jsdom](https://github.com/tmpvar/jsdom) which is essentially a headless browser
implemented completely in JS.
Expand All @@ -16,7 +16,6 @@ import sinon from 'sinon';
import Foo from './Foo';

describe('<Foo />', () => {

it('calls componentDidMount', () => {
sinon.spy(Foo.prototype, 'componentDidMount');
const wrapper = mount(<Foo />);
Expand All @@ -25,20 +24,19 @@ describe('<Foo />', () => {

it('allows us to set props', () => {
const wrapper = mount(<Foo bar="baz" />);
expect(wrapper.props().bar).to.equal("baz");
wrapper.setProps({ bar: "foo" });
expect(wrapper.props().bar).to.equal("foo");
expect(wrapper.props().bar).to.equal('baz');
wrapper.setProps({ bar: 'foo' });
expect(wrapper.props().bar).to.equal('foo');
});

it('simulates click events', () => {
const onButtonClick = sinon.spy();
const wrapper = mount(
const wrapper = mount((
<Foo onButtonClick={onButtonClick} />
);
));
wrapper.find('button').simulate('click');
expect(onButtonClick.calledOnce).to.equal(true);
});

});
```

Expand Down
9 changes: 4 additions & 5 deletions docs/api/render.md
Expand Up @@ -28,14 +28,13 @@ describe('<Foo />', () => {

it('rendered the title', () => {
const wrapper = render(<Foo title="unique" />);
expect(wrapper.text()).to.contain("unique");
expect(wrapper.text()).to.contain('unique');
});

it('can pass in context', () => {
class SimpleComponent extends React.Component {
render() {
return <div>{this.context.name}</div>;
}
function SimpleComponent(props, context) {
const { name } = context;
return <div>{name}</div>;
}
SimpleComponent.contextTypes = {
name: PropTypes.string,
Expand Down
32 changes: 16 additions & 16 deletions docs/api/selector.md
Expand Up @@ -20,15 +20,15 @@ in combination of the expected string syntax. For example, the following
is supported:

```js
const wrapper = mount(
const wrapper = mount((
<div>
<span foo={3} bar={false} title="baz" />
</div>
)
));

wrapper.find('[foo=3]')
wrapper.find('[bar=false]')
wrapper.find('[title="baz"]')
wrapper.find('[foo=3]');
wrapper.find('[bar=false]');
wrapper.find('[title="baz"]');
```

Further, enzyme supports combining any of those supported syntaxes together to uniquely identify a
Expand Down Expand Up @@ -64,8 +64,8 @@ Enzyme allows you to find components based on their constructor. You can pass in
the component's constructor:

```jsx
class MyComponent extends React.Component {
render() { ... }
function MyComponent() {
return <div />;
}

// find instances of MyComponent
Expand All @@ -82,13 +82,13 @@ a string can be used to find it:


```jsx
class MyComponent extends React.Component {
render() { ... }
function MyComponent() {
return <div />;
}
MyComponent.displayName = 'MyComponent';
MyComponent.displayName = 'MyComponent!';

// find instances of MyComponent
const myComponents = wrapper.find('MyComponent');
const myComponents = wrapper.find('MyComponent!');
```

NOTE: This will *only* work if the selector (and thus the component's `displayName`) is a string
Expand All @@ -103,13 +103,13 @@ Enzyme allows you to find components and nodes based on a subset of their proper


```jsx
const wrapper = mount(
const wrapper = mount((
<div>
<span foo={3} bar={false} title="baz" />
</div>
)
));

wrapper.find({ foo: 3 })
wrapper.find({ bar: false })
wrapper.find({ title: 'baz'})
wrapper.find({ foo: 3 });
wrapper.find({ bar: false });
wrapper.find({ title: 'baz' });
```
10 changes: 3 additions & 7 deletions docs/api/shallow.md
Expand Up @@ -7,7 +7,6 @@ that your tests aren't indirectly asserting on behavior of child components.
import { shallow } from 'enzyme';

describe('<MyComponent />', () => {

it('should render three <Foo /> components', () => {
const wrapper = shallow(<MyComponent />);
expect(wrapper.find(Foo)).to.have.length(3);
Expand All @@ -19,23 +18,20 @@ describe('<MyComponent />', () => {
});

it('should render children when passed in', () => {
const wrapper = shallow(
const wrapper = shallow((
<MyComponent>
<div className="unique" />
</MyComponent>
);
));
expect(wrapper.contains(<div className="unique" />)).to.equal(true);
});

it('simulates click events', () => {
const onButtonClick = sinon.spy();
const wrapper = shallow(
<Foo onButtonClick={onButtonClick} />
);
const wrapper = shallow(<Foo onButtonClick={onButtonClick} />);
wrapper.find('button').simulate('click');
expect(onButtonClick.calledOnce).to.equal(true);
});

});

```
Expand Down

0 comments on commit c2cb3a3

Please sign in to comment.