Skip to content

Commit

Permalink
Merge pull request #407 from marcin-mazurek/missing-index-param-forea…
Browse files Browse the repository at this point in the history
…ch-map

Add documentation and unit tests for index parameter for map and forEach methods
  • Loading branch information
aweary committed May 23, 2016
2 parents ddd5028 + b7e46e4 commit de88e95
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/forEach.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ wrapper around the corresponding node passed in as the first argument.

#### Arguments

1. `fn` (`Function ( ReactWrapper node )`): A callback to be run for every node in the collection.
1. `fn` (`Function ( ReactWrapper node, Number index )`): A callback to be run for every node in the collection.
Should expect a ReactWrapper as the first argument, and will be run with a context of the original
instance.

Expand Down
2 changes: 1 addition & 1 deletion docs/api/ReactWrapper/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to the map function.

#### Arguments

1. `fn` (`Function ( ReactWrapper node ) => Any`): A mapping function to be run for every node in
1. `fn` (`Function ( ReactWrapper node, Number index ) => Any`): A mapping function to be run for every node in
the collection, the results of which will be mapped to the returned array. Should expect a ReactWrapper as the first argument, and will be run with a context of
the original instance.

Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/forEach.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ wrapper around the corresponding node passed in as the first argument.

#### Arguments

1. `fn` (`Function ( ShallowWrapper node )`): A callback to be run for every node in the collection.
1. `fn` (`Function ( ShallowWrapper node, Number index )`): A callback to be run for every node in the collection.
Should expect a ShallowWrapper as the first argument, and will be run with a context of the original
instance.

Expand Down
2 changes: 1 addition & 1 deletion docs/api/ShallowWrapper/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to the map function.

#### Arguments

1. `fn` (`Function ( ShallowWrapper node ) => Any`): A mapping function to be run for every node in
1. `fn` (`Function ( ShallowWrapper node, Number index ) => Any`): A mapping function to be run for every node in
the collection, the results of which will be mapped to the returned array. Should expect a ShallowWrapper as the first argument, and will be run with a context of
the original instance.

Expand Down
6 changes: 6 additions & 0 deletions test/ReactWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1778,10 +1778,13 @@ describeWithDOM('mount', () => {
expect(spy.callCount).to.equal(3);
expect(spy.args[0][0]).to.be.instanceOf(ReactWrapper);
expect(spy.args[0][0].hasClass('bax')).to.equal(true);
expect(spy.args[0][1]).to.equal(0);
expect(spy.args[1][0]).to.be.instanceOf(ReactWrapper);
expect(spy.args[1][0].hasClass('bar')).to.equal(true);
expect(spy.args[1][1]).to.equal(1);
expect(spy.args[2][0]).to.be.instanceOf(ReactWrapper);
expect(spy.args[2][0].hasClass('baz')).to.equal(true);
expect(spy.args[2][1]).to.equal(2);
});
});

Expand All @@ -1801,10 +1804,13 @@ describeWithDOM('mount', () => {
expect(spy.callCount).to.equal(3);
expect(spy.args[0][0]).to.be.instanceOf(ReactWrapper);
expect(spy.args[0][0].hasClass('bax')).to.equal(true);
expect(spy.args[0][1]).to.equal(0);
expect(spy.args[1][0]).to.be.instanceOf(ReactWrapper);
expect(spy.args[1][0].hasClass('bar')).to.equal(true);
expect(spy.args[1][1]).to.equal(1);
expect(spy.args[2][0]).to.be.instanceOf(ReactWrapper);
expect(spy.args[2][0].hasClass('baz')).to.equal(true);
expect(spy.args[2][1]).to.equal(2);
});

it('should return an array with the mapped values', () => {
Expand Down
6 changes: 6 additions & 0 deletions test/ShallowWrapper-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1712,10 +1712,13 @@ describe('shallow', () => {
expect(spy.callCount).to.equal(3);
expect(spy.args[0][0]).to.be.instanceOf(ShallowWrapper);
expect(spy.args[0][0].hasClass('bax')).to.equal(true);
expect(spy.args[0][1]).to.equal(0);
expect(spy.args[1][0]).to.be.instanceOf(ShallowWrapper);
expect(spy.args[1][0].hasClass('bar')).to.equal(true);
expect(spy.args[1][1]).to.equal(1);
expect(spy.args[2][0]).to.be.instanceOf(ShallowWrapper);
expect(spy.args[2][0].hasClass('baz')).to.equal(true);
expect(spy.args[2][1]).to.equal(2);
});
});

Expand All @@ -1735,10 +1738,13 @@ describe('shallow', () => {
expect(spy.callCount).to.equal(3);
expect(spy.args[0][0]).to.be.instanceOf(ShallowWrapper);
expect(spy.args[0][0].hasClass('bax')).to.equal(true);
expect(spy.args[0][1]).to.equal(0);
expect(spy.args[1][0]).to.be.instanceOf(ShallowWrapper);
expect(spy.args[1][0].hasClass('bar')).to.equal(true);
expect(spy.args[1][1]).to.equal(1);
expect(spy.args[2][0]).to.be.instanceOf(ShallowWrapper);
expect(spy.args[2][0].hasClass('baz')).to.equal(true);
expect(spy.args[2][1]).to.equal(2);
});

it('should return an array with the mapped values', () => {
Expand Down

0 comments on commit de88e95

Please sign in to comment.