Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find now supports more css selectors #37

Merged
merged 4 commits into from
Jan 19, 2016
Merged

Conversation

NickStefan
Copy link
Contributor

Find now can now support this:

.find( 'span.test-class[data-selector]' )
.test(function(){
   var text = this.elements[ ' span.test-class[data-selector]'  ].innerHTML;
});

However, this creates a breaking change:
Class selectors are no longer stripped of leading "." . This is for consistency that selectors simply are selectors. This means that often you need to access elements using the key syntax: this.elements[ ".class-test"]. This also means some fancy es6 object destructuring won't work as well.

// this will no longer work
Test(<TestComponent/>)
.find('.box')
.test(({box}) => {
  expect(box.props.children).to.be.equal('found me!')
})

 // but this will
Test(<TestComponent/>)
.find('.box')
.elements('.box', (box) => {
  expect(box.props.children).to.be.equal('found me!')
})

I think it is VERY worth it. We've been using this project at my job, and I've found that more specific selectors are very useful for testing. I made a mixin to do this, but I also thought I'd attempt a PR with it. Tests passing, linter passing. Had to change a few tests due to the breaking changes noted above.

* 'master' of github.com:Legitcode/tests:
  updated version with latest code
  Remove double babel dependency
  Add harmony-reflect as dependency
  version bump for 0.6.2
  Fixed find middleware when selector is a component created with createClass
  version bump for component
  Add component to 'this' for mixins

Conflicts:
	package.json
	src/middleware/find.js
@NickStefan
Copy link
Contributor Author

fixes #35

@zackify
Copy link
Member

zackify commented Jan 19, 2016

I'll check this out tonight and I'll merge it with a major version bump.
I'm sure it's all fine!
On Tue, Jan 19, 2016 at 13:38 Nick Stefan notifications@github.com wrote:

fixes #35 #35


Reply to this email directly or view it on GitHub
#37 (comment).

zackify added a commit that referenced this pull request Jan 19, 2016
find now supports more css selectors
@zackify zackify merged commit 23f20de into Legitcode:master Jan 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants