Skip to content

Commit

Permalink
fixes #590: change isCompoundSelector to not match prop selector
Browse files Browse the repository at this point in the history
  • Loading branch information
joeduncan authored and lencioni committed Oct 12, 2016
1 parent 58764f1 commit 19d06e8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utils.js
Expand Up @@ -195,7 +195,7 @@ export function selectorError(selector, type = '') {
);
}

export const isCompoundSelector = /([a-z]\.[a-z]|[a-z]\[.*\]|[a-z]#[a-z])/i;
export const isCompoundSelector = /^[\.#]?-?[_a-z]+[_a-z0-9-]*[\.\[#]/i;

const isPropSelector = /^\[.*\]$/;

Expand Down
44 changes: 44 additions & 0 deletions test/ShallowWrapper-spec.jsx
Expand Up @@ -340,6 +340,50 @@ describe('shallow', () => {
expect(wrapper.find('.foo').type()).to.equal('input');
});

it('should find an element that has dot in attribute', () => {
const wrapper = shallow(
<div>
<div data-baz="foo.bar" />
</div>
);

const elements = wrapper.find('[data-baz="foo.bar"]');
expect(elements.length).to.equal(1);
});

it('should find an element that with class and attribute', () => {
const wrapper = shallow(
<div>
<div data-baz="bar" className="classBar" />
</div>
);

const elements = wrapper.find('.classBar[data-baz="bar"]');
expect(elements.length).to.equal(1);
});

it('should find an element that with multiple classes and one attribute', () => {
const wrapper = shallow(
<div>
<div data-baz="bar" className="classBar classFoo" />
</div>
);

const elements = wrapper.find('.classBar.classFoo[data-baz="bar"]');
expect(elements.length).to.equal(1);
});

it('should find an element that with class and class with hyphen', () => {
const wrapper = shallow(
<div>
<div data-baz="bar" className="classBar class-Foo" />
</div>
);

const elements = wrapper.find('.classBar.class-Foo');
expect(elements.length).to.equal(1);
});

it('should find an element based on a tag name and class name', () => {
const wrapper = shallow(
<div>
Expand Down

0 comments on commit 19d06e8

Please sign in to comment.