Skip to content

Commit

Permalink
[Docs] clean up linting errors in ShallowWrapper API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 17, 2017
1 parent c2cb3a3 commit 0676ee7
Show file tree
Hide file tree
Showing 39 changed files with 224 additions and 251 deletions.
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/at.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Returns a wrapper around the node at a given index of the current wrapper.

```jsx
const wrapper = shallow(<MyComponent />);
expect(wrapper.find(Foo).at(0).props().foo).to.equal("bar");
expect(wrapper.find(Foo).at(0).props().foo).to.equal('bar');
```


Expand Down
8 changes: 4 additions & 4 deletions docs/api/ShallowWrapper/contains.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ the ones passed in.


```jsx
const wrapper = shallow(
const wrapper = shallow((
<div>
<div data-foo="foo" data-bar="bar">Hello</div>
</div>
);
));

expect(wrapper.contains(<div data-foo="foo" data-bar="bar">Hello</div>)).to.equal(true);

Expand All @@ -37,13 +37,13 @@ expect(wrapper.contains(<div data-foo="foo" data-bar="bar" />)).to.equal(false);
```

```jsx
const wrapper = shallow(
const wrapper = shallow((
<div>
<span>Hello</span>
<div>Goodbye</div>
<span>Again</span>
</div>
);
));

expect(wrapper.contains([
<span>Hello</span>,
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/containsAllMatchingElements.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ like the nodes passed in.


```jsx
const wrapper = shallow(
const wrapper = shallow((
<div>
<span className="foo">Hello</span>
<div style={{ fontSize: 13 }}>Goodbye</div>
<span>Again</span>
</div>
);
));

expect(wrapper.containsAllMatchingElements([
<span>Hello</span>,
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/containsAnyMatchingElements.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ like one of the array passed in.


```jsx
const wrapper = shallow(
const wrapper = shallow((
<div>
<span className="foo">Hello</span>
<div style={{ fontSize: 13 }}>Goodbye</div>
<span>Again</span>
</div>
);
));

expect(wrapper.containsAnyMatchingElements([
<span>Bonjour</span>,
Expand Down
28 changes: 9 additions & 19 deletions docs/api/ShallowWrapper/containsMatchingElement.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,18 @@ the one passed in.


```jsx
const wrapper = shallow(
const wrapper = shallow((
<div>
<div data-foo="foo" data-bar="bar">Hello</div>
</div>
);

expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="bar">Hello</div>
)).to.equal(true);
expect(wrapper.containsMatchingElement(
<div data-foo="foo">Hello</div>
)).to.equal(true);

expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="bar" data-baz="baz">Hello</div>
)).to.equal(false);
expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="Hello">Hello</div>
)).to.equal(false);
expect(wrapper.containsMatchingElement(
<div data-foo="foo" data-bar="bar" />
)).to.equal(false);
));

expect(wrapper.containsMatchingElement(<div data-foo="foo" data-bar="bar">Hello</div>)).to.equal(true);
expect(wrapper.containsMatchingElement(<div data-foo="foo">Hello</div>)).to.equal(true);

expect(wrapper.containsMatchingElement(<div data-foo="foo" data-bar="bar" data-baz="baz">Hello</div>)).to.equal(false);
expect(wrapper.containsMatchingElement(<div data-foo="foo" data-bar="Hello">Hello</div>)).to.equal(false);
expect(wrapper.containsMatchingElement(<div data-foo="foo" data-bar="bar" />)).to.equal(false);
```

#### Common Gotchas
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ root component instance.
```jsx
const wrapper = shallow(
<MyComponent />,
{ context: { foo: 10 } }
{ context: { foo: 10 } },
);
expect(wrapper.context().foo).to.equal(10);
expect(wrapper.context('foo')).to.equal(10);
Expand Down
31 changes: 17 additions & 14 deletions docs/api/ShallowWrapper/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@ console when tests are not passing when you expect them to.

#### Examples
```jsx
class Book extends React.Component {
render() {
const { title, cover } = this.props;
return (
<div>
<h1 className="title">{title}</h1>
{cover && <BookCover cover={cover} />}
</div>
);
}
function Book({ title, cover }) {
return (
<div>
<h1 className="title">{title}</h1>
{cover && <BookCover cover={cover} />}
</div>
);
}

Book.propTypes = {
title: PropTypes.string.isRequired,
cover: PropTypes.string,
};
Book.defaultProps = {
cover: null,
};
```
```jsx
const wrapper = shallow(<Book title="Huckleberry Finn" />);
Expand All @@ -37,16 +40,16 @@ Outputs to console:
```

```jsx
const wrapper = shallow(
const wrapper = shallow((
<Book
title="Huckleberry Finn"
cover={{
url: 'http://some.url/to/img.png',
width: 40,
height: 80
height: 80,
}}
/>
);
));
console.log(wrapper.debug());
```
Outputs to console:
Expand Down
28 changes: 12 additions & 16 deletions docs/api/ShallowWrapper/dive.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,22 @@ NOTE: can only be called on wrapper of a single non-DOM component element node.
#### Examples

```jsx
class Bar extends React.Component {
render() {
return (
<div>
<div className="in-bar" />
</div>
);
}
function Bar() {
return (
<div>
<div className="in-bar" />
</div>
);
}
```

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

Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/every.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Returns whether or not all of the nodes in the wrapper match the provided select
#### Examples

```jsx
const wrapper = shallow(
const wrapper = shallow((
<div>
<div className="foo qoo" />
<div className="foo boo" />
<div className="foo hoo" />
</div>
);
));
expect(wrapper.find('.foo').every('.foo')).to.equal(true);
expect(wrapper.find('.foo').every('.qoo')).to.equal(false);
expect(wrapper.find('.foo').every('.bar')).to.equal(false);
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/everyWhere.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Returns whether or not all of the nodes in the wrapper pass the provided predica
#### Example

```jsx
const wrapper = shallow(
const wrapper = shallow((
<div>
<div className="foo qoo" />
<div className="foo boo" />
<div className="foo hoo" />
</div>
);
));
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('foo'))).to.equal(true);
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('qoo'))).to.equal(false);
expect(wrapper.find('.foo').everyWhere(n => n.hasClass('bar'))).to.equal(false);
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/find.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ expect(wrapper.find('Foo')).to.have.length(1);
Object Property Selector:
```jsx
const wrapper = shallow(<MyComponent />);
expect(wrapper.find({prop: 'value'})).to.have.length(1);
expect(wrapper.find({ prop: 'value' })).to.have.length(1);
```


Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/first.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Reduce the set of matched nodes to the first in the set.

```jsx
const wrapper = shallow(<MyComponent />);
expect(wrapper.find(Foo).first().props().foo).to.equal("bar");
expect(wrapper.find(Foo).first().props().foo).to.equal('bar');
```
6 changes: 3 additions & 3 deletions docs/api/ShallowWrapper/forEach.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ instance.
#### Example

```jsx
const wrapper = shallow(
const wrapper = shallow((
<div>
<div className="foo bax" />
<div className="foo bar" />
<div className="foo baz" />
</div>
);
));

wrapper.find('.foo').forEach(function (node) {
wrapper.find('.foo').forEach((node) => {
expect(node.hasClass('foo')).to.equal(true);
});
```
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Returns the node at a given index of the current wrapper.

```jsx
const wrapper = shallow(<MyComponent />);
expect(wrapper.find(Foo).get(0).props.foo).to.equal("bar");
expect(wrapper.find(Foo).get(0).props.foo).to.equal('bar');
```


Expand Down
14 changes: 6 additions & 8 deletions docs/api/ShallowWrapper/getNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ If the current wrapper is wrapping the root component, returns the root componen

```jsx
const element = (
<div>
<span />
<span />
</div>
<div>
<span />
<span />
</div>
);

class MyComponent extends React.Component {
render() {
return element;
}
function MyComponent() {
return element;
}

const wrapper = shallow(<MyComponent />);
Expand Down
16 changes: 7 additions & 9 deletions docs/api/ShallowWrapper/getNodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ If the current wrapper is wrapping the root component, returns the root componen
const one = <span />;
const two = <span />;

class Test extends React.Component {
render() {
return (
<div>
{ one }
{ two }
</div>
);
}
function Test() {
return (
<div>
{one}
{two}
</div>
);
}

const wrapper = shallow(<Test />);
Expand Down
28 changes: 10 additions & 18 deletions docs/api/ShallowWrapper/html.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,25 @@ Note: can only be called on a wrapper of a single node.
#### Examples

```jsx
class Foo extends React.Component {
render() {
return (<div className="in-foo" />);
}
function Foo() {
return (<div className="in-foo" />);
}
```

```jsx
class Bar extends React.Component {
render() {
return (
<div className="in-bar">
<Foo />
</div>
);
}
function Bar() {
return (
<div className="in-bar">
<Foo />
</div>
);
}
```

```jsx
const wrapper = shallow(<Bar />);
expect(wrapper.html()).to.equal(
`<div class="in-bar"><div class="in-foo"></div></div>`
);
expect(wrapper.find(Foo).html()).to.equal(
`<div class="in-foo"></div>`
);
expect(wrapper.html()).to.equal('<div class="in-bar"><div class="in-foo"></div></div>');
expect(wrapper.find(Foo).html()).to.equal('<div class="in-foo"></div>');
```

```jsx
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ShallowWrapper/key.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ NOTE: can only be called on a wrapper of a single node.


```jsx
const wrapper = shallow(
const wrapper = shallow((
<ul>
{['foo', 'bar'].map(s => <li key={s}>{s}</li>)}
</ul>
).find('li');
)).find('li');
expect(wrapper.at(0).key()).to.equal('foo');
expect(wrapper.at(1).key()).to.equal('bar');
```
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/last.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Reduce the set of matched nodes to the last in the set.

```jsx
const wrapper = shallow(<MyComponent />);
expect(wrapper.find(Foo).last().props().foo).to.equal("bar");
expect(wrapper.find(Foo).last().props().foo).to.equal('bar');
```
Loading

0 comments on commit 0676ee7

Please sign in to comment.