diff --git a/src/index.js b/src/index.js index c157ffe..7c0cd59 100644 --- a/src/index.js +++ b/src/index.js @@ -17,7 +17,8 @@ export default function linkState(component, key, eventPath) { v = typeof eventPath==='string' ? delve(e, eventPath) : t.nodeName ? (t.type.match(/^che|rad/) ? t.checked : t.value) : e, i = 0; for ( ; i { expect(component.setState).to.have.been.calledWith({nested: {state: {key: 'newValue'}}}); }); + it('should set dot notated state key with index support appropriately', () => { + linkFunction = linkState(component,'nested.state.0.key'); + let element = document.createElement('input'); + element.type= 'text'; + element.value = 'newValue'; + + linkFunction({ + currentTarget: element, + target: element + }); + + expect(component.setState).to.have.been.calledOnce; + expect(component.setState).to.have.been.calledWith({nested: {state: [{key: 'newValue'}]}}); + }); + }); describe('linkState with eventPath argument', () => {