Skip to content

Commit

Permalink
[Docs] clean up linting errors in ReactWrapper API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 17, 2017
1 parent 0676ee7 commit 12cdf2d
Show file tree
Hide file tree
Showing 38 changed files with 161 additions and 182 deletions.
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/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 = mount(<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/ReactWrapper/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 = mount(
const wrapper = mount((
<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 = mount(
const wrapper = mount((
<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/ReactWrapper/containsAllMatchingElements.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ like the nodes passed in.


```jsx
const wrapper = mount(
const wrapper = mount((
<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/ReactWrapper/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 = mount(
const wrapper = mount((
<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/ReactWrapper/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 = mount(
const wrapper = mount((
<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/ReactWrapper/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ root component instance.
```jsx
const wrapper = mount(
<MyComponent />,
{ context: { foo: 10 } }
{ context: { foo: 10 } },
);

expect(wrapper.context().foo).to.equal(10);
Expand Down
32 changes: 15 additions & 17 deletions docs/api/ReactWrapper/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,21 @@ console when tests are not passing when you expect them to.

Say we have the following components:
```jsx
class Foo extends React.Component {
render() {
return (
<div className="foo">
<span>Foo</span>
</div>
);
}
function Foo() {
return (
<div className="foo">
<span>Foo</span>
</div>
);
}

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

Expand All @@ -42,6 +38,7 @@ console.log(mount(<Bar id="2" />).debug());
```

Would output the following to the console:
<!-- eslint-disable -->
```jsx
<Bar id="2">
<div className="bar">
Expand All @@ -65,6 +62,7 @@ Likewise, running:
console.log(mount(<Bar id="2" />).find(Foo).debug());
```
Would output the following to the console:
<!-- eslint-disable -->
```jsx
<Foo baz="bax">
<div className="foo">
Expand Down
4 changes: 2 additions & 2 deletions docs/api/ReactWrapper/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 = mount(
const wrapper = mount((
<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/ReactWrapper/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 = mount(
const wrapper = mount((
<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/ReactWrapper/find.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ expect(wrapper.find('Foo')).to.have.length(1);
Object Property Selector:
```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.find({prop: 'value'})).to.have.length(1);
expect(wrapper.find({ prop: 'value' })).to.have.length(1);
```

#### Related Methods
Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/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 = mount(<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/ReactWrapper/forEach.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ instance.
#### Example

```jsx
const wrapper = mount(
const wrapper = mount((
<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/ReactWrapper/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 = mount(<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
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/getDOMNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Notes:

```jsx
const wrapper = mount(<MyComponent />);
expect(wrapper.getDOMNode()).to.have.property("className");
expect(wrapper.getDOMNode()).to.have.property('className');
```
16 changes: 7 additions & 9 deletions docs/api/ReactWrapper/getNode.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ Returns the wrapper's underlying node.
#### Examples

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

const wrapper = mount(<Test />);
Expand Down
16 changes: 7 additions & 9 deletions docs/api/ReactWrapper/getNodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ Returns the wrapper's underlying nodes.
#### Examples

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

const wrapper = mount(<Test />);
Expand Down
28 changes: 10 additions & 18 deletions docs/api/ReactWrapper/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 = mount(<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/ReactWrapper/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 = mount(
const wrapper = mount((
<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/ReactWrapper/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 = mount(<MyComponent />);
expect(wrapper.find(Foo).last().props().foo).to.equal("bar");
expect(wrapper.find(Foo).last().props().foo).to.equal('bar');
```
6 changes: 3 additions & 3 deletions docs/api/ReactWrapper/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ the original instance.
#### Example

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

const texts = wrapper.find('.foo').map(node => node.text());
expect(texts).to.eql([ 'bax', 'bar', 'baz' ]);
expect(texts).to.eql(['bax', 'bar', 'baz']);
```


Expand Down
Loading

0 comments on commit 12cdf2d

Please sign in to comment.