@@ -855,7 +857,6 @@ describeWithDOM('mount', () => {
});
describe('.setProps(newProps)', () => {
-
it('should set props for a component multiple times', () => {
class Foo extends React.Component {
render() {
@@ -873,7 +874,6 @@ describeWithDOM('mount', () => {
});
it('should call componentWillReceiveProps for new renders', () => {
-
const spy = sinon.spy();
class Foo extends React.Component {
@@ -901,10 +901,15 @@ describeWithDOM('mount', () => {
class Foo extends React.Component {
render() {
return (
-
);
}
}
+ class Bar extends React.Component {
+ render() {
+ return
);
expect(wrapper.props().a).to.equal('a');
@@ -929,8 +934,9 @@ describeWithDOM('mount', () => {
}
const similarException = ((() => {
+ const user = {};
try {
- return undefined.givenName;
+ return user.name.givenName;
} catch (e) {
return e;
}
@@ -955,7 +961,7 @@ describeWithDOM('mount', () => {
describeIf(!REACT013, 'stateless function components', () => {
it('should set props for a component multiple times', () => {
- const Foo = (props) => (
+ const Foo = props => (
@@ -968,8 +974,11 @@ describeWithDOM('mount', () => {
});
it('should merge newProps with oldProps', () => {
- const Foo = (props) => (
-
);
@@ -996,8 +1005,9 @@ describeWithDOM('mount', () => {
};
const similarException = ((() => {
+ const user = {};
try {
- return undefined.givenName;
+ return user.name.givenName;
} catch (e) {
return e;
}
@@ -1145,13 +1155,10 @@ describeWithDOM('mount', () => {
wrapper.unmount();
expect(spy.calledOnce).to.equal(true);
});
-
});
describe('.simulate(eventName, data)', () => {
-
it('should simulate events', () => {
-
class Foo extends React.Component {
constructor(props) {
super(props);
@@ -1180,7 +1187,6 @@ describeWithDOM('mount', () => {
expect(wrapper.find('.clicks-0').length).to.equal(1);
wrapper.simulate('click');
expect(wrapper.find('.clicks-1').length).to.equal(1);
-
});
it('should pass in event data', () => {
@@ -1470,7 +1476,6 @@ describeWithDOM('mount', () => {
});
describe('.text()', () => {
-
const matchesRender = function matchesRender(node) {
const actual = mount(node).text();
const expected = render(node).text();
@@ -1525,7 +1530,7 @@ describeWithDOM('mount', () => {
describeIf(!REACT013, 'stateless function components', () => {
it('should handle nodes with mapped children', () => {
- const Foo = (props) => (
+ const Foo = props => (
);
@@ -1556,7 +1561,6 @@ describeWithDOM('mount', () => {
});
describe('.props()', () => {
-
it('should return the props object', () => {
const fn = () => ({});
const wrapper = mount(
@@ -1569,7 +1573,6 @@ describeWithDOM('mount', () => {
expect(wrapper.props().className).to.equal('bax');
expect(wrapper.props().onClick).to.equal(fn);
expect(wrapper.props().id).to.equal('fooId');
-
});
it('should be allowed to be used on an inner node', () => {
@@ -1613,7 +1616,6 @@ describeWithDOM('mount', () => {
});
describe('.prop(name)', () => {
-
it('should return the props of key `name`', () => {
const fn = () => ({});
const wrapper = mount(
@@ -1626,7 +1628,6 @@ describeWithDOM('mount', () => {
expect(wrapper.prop('className')).to.equal('bax');
expect(wrapper.prop('onClick')).to.equal(fn);
expect(wrapper.prop('id')).to.equal('fooId');
-
});
it('should be allowed to be used on an inner node', () => {
@@ -1676,7 +1677,6 @@ describeWithDOM('mount', () => {
});
describe('.state(name)', () => {
-
it('should return the state object', () => {
class Foo extends React.Component {
constructor(props) {
@@ -1790,7 +1790,7 @@ describeWithDOM('mount', () => {
describeIf(!REACT013, 'stateless function components', () => {
it('should handle mixed children with and without arrays', () => {
- const Foo = (props) => (
+ const Foo = props => (
{props.items.map(x => x)}
@@ -1845,7 +1845,6 @@ describeWithDOM('mount', () => {
expect(parents.at(0).hasClass('bar')).to.equal(true);
expect(parents.at(1).hasClass('foo')).to.equal(true);
expect(parents.at(2).hasClass('bax')).to.equal(true);
-
});
it('should work for non-leaf nodes as well', () => {
@@ -2320,15 +2319,15 @@ describeWithDOM('mount', () => {
render() {
return (
- First
- Second
- Third
+ First
+ Second
+ Third
);
}
}
const wrapper = mount(
);
- expect(wrapper.ref('secondRef').prop('amount')).to.equal(4);
+ expect(wrapper.ref('secondRef').prop('data-amount')).to.equal(4);
expect(wrapper.ref('secondRef').text()).to.equal('Second');
});
});
@@ -2447,25 +2446,27 @@ describeWithDOM('mount', () => {
}
}
const div = global.document.createElement('div');
+
+ const initialBodyChildren = document.body.childNodes.length;
global.document.body.appendChild(div);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);
const wrapper = mount(
, { attachTo: div });
expect(wrapper.find('.in-foo')).to.have.length(1);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);
wrapper.detach();
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);
global.document.body.removeChild(div);
- expect(document.body.childNodes).to.have.length(0);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren);
expect(div.childNodes).to.have.length(0);
});
@@ -2482,15 +2483,17 @@ describeWithDOM('mount', () => {
}
let wrapper;
const div = global.document.createElement('div');
+
+ const initialBodyChildren = document.body.childNodes.length;
global.document.body.appendChild(div);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);
wrapper = mount(
, { attachTo: div });
expect(wrapper.find('.in-foo')).to.have.length(1);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);
wrapper.detach();
@@ -2498,17 +2501,17 @@ describeWithDOM('mount', () => {
wrapper = mount(
, { attachTo: div });
expect(wrapper.find('.in-bar')).to.have.length(1);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);
wrapper.detach();
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);
global.document.body.removeChild(div);
- expect(document.body.childNodes).to.have.length(0);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren);
expect(div.childNodes).to.have.length(0);
});
@@ -2627,25 +2630,26 @@ describeWithDOM('mount', () => {
const Foo = () =>
;
const div = global.document.createElement('div');
+ const initialBodyChildren = document.body.childNodes.length;
global.document.body.appendChild(div);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);
const wrapper = mount(
, { attachTo: div });
expect(wrapper.find('.in-foo')).to.have.length(1);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);
wrapper.detach();
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);
global.document.body.removeChild(div);
- expect(document.body.childNodes).to.have.length(0);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren);
expect(div.childNodes).to.have.length(0);
});
@@ -2655,15 +2659,16 @@ describeWithDOM('mount', () => {
let wrapper;
const div = global.document.createElement('div');
+ const initialBodyChildren = document.body.childNodes.length;
global.document.body.appendChild(div);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);
wrapper = mount(
, { attachTo: div });
expect(wrapper.find('.in-foo')).to.have.length(1);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);
wrapper.detach();
@@ -2671,17 +2676,17 @@ describeWithDOM('mount', () => {
wrapper = mount(
, { attachTo: div });
expect(wrapper.find('.in-bar')).to.have.length(1);
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(1);
wrapper.detach();
- expect(document.body.childNodes).to.have.length(1);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 1);
expect(div.childNodes).to.have.length(0);
global.document.body.removeChild(div);
- expect(document.body.childNodes).to.have.length(0);
+ expect(document.body.childNodes).to.have.length(initialBodyChildren + 0);
expect(div.childNodes).to.have.length(0);
});
@@ -3005,5 +3010,18 @@ describeWithDOM('mount', () => {
expect(wrapper.name()).to.equal('div');
});
});
+
+ describe('.ref()', () => {
+ it('unavailable ref should return empty nodes', () => {
+ class WithoutRef extends React.Component {
+ render() { return
; }
+ }
+ const wrapper = mount(
);
+ const ref = wrapper.ref('not-a-ref');
+
+ expect(ref.length).to.equal(0);
+ expect(ref.isEmpty()).to.equal(true);
+ });
+ });
});
});
diff --git a/test/ShallowTraversal-spec.jsx b/test/ShallowTraversal-spec.jsx
index f31eed347..5b5862391 100644
--- a/test/ShallowTraversal-spec.jsx
+++ b/test/ShallowTraversal-spec.jsx
@@ -112,6 +112,42 @@ describe('ShallowTraversal', () => {
expect(nodeHasProperty(
, 'foo', '-Infinity')).to.equal(true);
});
+ it('should parse zeroes properly', () => {
+ expect(nodeHasProperty(
, 'foo', '0')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', '-0')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', '0')).to.equal(false);
+ expect(nodeHasProperty(
, 'foo', '-0')).to.equal(false);
+ });
+
+ it('should work with empty strings', () => {
+ expect(nodeHasProperty(
, 'foo', '')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', '""')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', '')).to.equal(false);
+ expect(nodeHasProperty(
, 'foo', '""')).to.equal(false);
+ });
+
+ it('should work with NaN', () => {
+ expect(nodeHasProperty(
, 'foo', 'NaN')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', 'NaN')).to.equal(false);
+ });
+
+ it('should work with null', () => {
+ expect(nodeHasProperty(
, 'foo', 'null')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', 'null')).to.equal(false);
+ });
+
+ it('should work with false', () => {
+ expect(nodeHasProperty(
, 'foo', 'false')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', 'false')).to.equal(false);
+ });
+
+ it('should work with ±Infinity', () => {
+ expect(nodeHasProperty(
, 'foo', 'Infinity')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', 'Infinity')).to.equal(false);
+ expect(nodeHasProperty(
, 'foo', '-Infinity')).to.equal(true);
+ expect(nodeHasProperty(
, 'foo', '-Infinity')).to.equal(false);
+ });
+
it('should throw when un unquoted string is passed in', () => {
const node = (
);
@@ -170,7 +206,7 @@ describe('ShallowTraversal', () => {
const spy = sinon.spy();
const node = (
);
treeForEach(node, spy);
diff --git a/test/ShallowWrapper-spec.jsx b/test/ShallowWrapper-spec.jsx
index 47b570f10..2d8e4bbc8 100644
--- a/test/ShallowWrapper-spec.jsx
+++ b/test/ShallowWrapper-spec.jsx
@@ -7,7 +7,6 @@ import { describeIf, itIf, itWithData, generateEmptyRenderData } from './_helper
import { REACT013, REACT15 } from '../src/version';
describe('shallow', () => {
-
describe('context', () => {
it('can pass in context', () => {
const SimpleComponent = React.createClass({
@@ -70,7 +69,7 @@ describe('shallow', () => {
);
const context = { name: 'foo' };
- expect(() => shallow(
, { context })).not.to.throw(Error);
+ expect(() => shallow(
, { context })).not.to.throw();
});
it('is instrospectable through context API', () => {
@@ -103,7 +102,6 @@ describe('shallow', () => {
});
describe('.instance()', () => {
-
it('should return the component instance', () => {
class Foo extends React.Component {
render() { return
; }
@@ -127,11 +125,9 @@ describe('shallow', () => {
'ShallowWrapper::instance() can only be called on the root'
);
});
-
});
describe('.contains(node)', () => {
-
it('should allow matches on the root node', () => {
const a =
;
const b =
;
@@ -253,7 +249,6 @@ describe('shallow', () => {
});
describe('.equals(node)', () => {
-
it('should allow matches on the root node', () => {
const a =
;
const b =
;
@@ -326,11 +321,9 @@ describe('shallow', () => {
expect(shallow(
).equals(
)).to.equal(false);
});
});
-
});
describe('.find(selector)', () => {
-
it('should be able to match the root DOM element', () => {
const wrapper = shallow(
hello
);
expect(wrapper.find('#ttt')).to.have.length(1);
@@ -626,7 +619,6 @@ describe('shallow', () => {
});
describe('.findWhere(predicate)', () => {
-
it('should return all elements for a truthy test', () => {
const wrapper = shallow(
@@ -732,7 +724,6 @@ describe('shallow', () => {
wrapper.findWhere(spy);
expect(spy.callCount).to.equal(2);
});
-
});
describe('.setProps(newProps)', () => {
@@ -782,7 +773,14 @@ describe('shallow', () => {
class Foo extends React.Component {
render() {
return (
-
+
+ );
+ }
+ }
+ class Bar extends React.Component {
+ render() {
+ return (
+
);
}
}
@@ -818,7 +816,7 @@ describe('shallow', () => {
describeIf(!REACT013, 'stateless function components', () => {
it('should set props for a component multiple times', () => {
- const Foo = (props) => (
+ const Foo = props => (
{props.id}
@@ -831,8 +829,11 @@ describe('shallow', () => {
});
it('should merge newProps with oldProps', () => {
- const Foo = (props) => (
-
+ const Foo = props => (
+
+ );
+ const Bar = () => (
+
);
const wrapper = shallow(
);
@@ -916,9 +917,7 @@ describe('shallow', () => {
});
describe('.simulate(eventName, data)', () => {
-
it('should simulate events', () => {
-
class Foo extends React.Component {
constructor(props) {
super(props);
@@ -945,7 +944,6 @@ describe('shallow', () => {
expect(wrapper.find('.clicks-0').length).to.equal(1);
wrapper.simulate('click');
expect(wrapper.find('.clicks-1').length).to.equal(1);
-
});
@@ -971,7 +969,7 @@ describe('shallow', () => {
describeIf(!REACT013, 'stateless function components', () => {
it('should simulate events', () => {
const spy = sinon.spy();
- const Foo = (props) => (
+ const Foo = props => (
foo
);
@@ -982,7 +980,6 @@ describe('shallow', () => {
expect(spy.calledOnce).to.equal(true);
});
-
it('should pass in event data', () => {
const spy = sinon.spy();
const Foo = () => (
@@ -1066,7 +1063,7 @@ describe('shallow', () => {
this.setState({ count: this.state.count + 1 });
}
render() {
- ++renderCount;
+ renderCount += 1;
return (
{this.state.count}
);
@@ -1078,7 +1075,6 @@ describe('shallow', () => {
expect(wrapper.text()).to.equal('1');
expect(renderCount).to.equal(2);
});
-
});
describe('.setState(newState)', () => {
@@ -1298,7 +1294,6 @@ describe('shallow', () => {
});
describe('.text()', () => {
-
const matchesRender = function matchesRender(node) {
const actual = shallow(node).text();
const expected = render(node).text();
@@ -1353,7 +1348,7 @@ describe('shallow', () => {
describeIf(!REACT013, 'stateless function components', () => {
it('should handle nodes with mapped children', () => {
- const Foo = (props) => (
+ const Foo = props => (
{props.items.map(x => x)}
@@ -1384,11 +1379,9 @@ describe('shallow', () => {
expect(wrapper.text()).to.equal('
test');
});
});
-
});
describe('.props()', () => {
-
it('should return the props object', () => {
const fn = () => ({});
const wrapper = shallow(
@@ -1445,7 +1438,6 @@ describe('shallow', () => {
});
describe('.prop(name)', () => {
-
it('should return the props of key `name`', () => {
const fn = () => ({});
const wrapper = shallow(
@@ -1647,7 +1639,7 @@ describe('shallow', () => {
describeIf(!REACT013, 'stateless function components', () => {
it('should handle mixed children with and without arrays', () => {
- const Foo = (props) => (
+ const Foo = props => (
{props.items.map(x => x)}
@@ -2292,7 +2284,6 @@ describe('shallow', () => {
});
});
});
-
});
describe('.first()', () => {
@@ -2429,7 +2420,6 @@ describe('shallow', () => {
);
});
});
-
});
describe('.unmount()', () => {
@@ -2457,7 +2447,6 @@ describe('shallow', () => {
});
describe('.render()', () => {
-
it('should return a cheerio wrapper around the current node', () => {
class Foo extends React.Component {
render() {
@@ -2498,7 +2487,6 @@ describe('shallow', () => {
expect(renderedFoo.find('.in-bar')).to.have.length(0);
});
});
-
});
describe('lifecycleExperimental', () => {
@@ -2554,7 +2542,6 @@ describe('shallow', () => {
});
context('updating props', () => {
-
it('should call shouldComponentUpdate, componentWillUpdate and componentDidUpdate', () => {
const spy = sinon.spy();
@@ -2739,11 +2726,9 @@ describe('shallow', () => {
expect(spy).to.have.property('callCount', 3);
expect(result.state('count')).to.equal(1);
});
-
});
context('updating state', () => {
-
it('should call shouldComponentUpdate, componentWillUpdate and componentDidUpdate', () => {
const spy = sinon.spy();
@@ -2899,11 +2884,9 @@ describe('shallow', () => {
expect(spy).to.have.property('callCount', 3);
expect(result.state('count')).to.equal(1);
});
-
});
context('updating context', () => {
-
it('should call shouldComponentUpdate, componentWillUpdate and componentDidUpdate', () => {
const spy = sinon.spy();
class Foo extends React.Component {
@@ -3070,12 +3053,10 @@ describe('shallow', () => {
expect(spy).to.have.property('callCount', 3);
expect(result.state('count')).to.equal(1);
});
-
});
context('unmounting phase', () => {
-
- it('should calll componentWillUnmount', () => {
+ it('should call componentWillUnmount', () => {
const spy = sinon.spy();
class Foo extends React.Component {
componentWillUnmount() {
@@ -3345,6 +3326,7 @@ describe('shallow', () => {
)).to.equal(false);
});
});
+
describe('.containsAllMatchingElements(nodes)', () => {
it('should match on an array of nodes that all looks like one of rendered nodes', () => {
const spy1 = sinon.spy();
@@ -3471,6 +3453,7 @@ describe('shallow', () => {
expect(spy2.callCount).to.equal(0);
});
});
+
describe('.name()', () => {
describe('node with displayName', () => {
it('should return the displayName of the node', () => {
@@ -3575,4 +3558,72 @@ describe('shallow', () => {
});
});
+ describe('.dive()', () => {
+ class RendersDOM extends React.Component {
+ render() {
+ return
;
+ }
+ }
+ class RendersNull extends React.Component {
+ render() {
+ return null;
+ }
+ }
+ class RendersMultiple extends React.Component {
+ render() {
+ return (
+
+
+
+
+ );
+ }
+ }
+ class WrapsRendersDOM extends React.Component {
+ render() {
+ return
;
+ }
+ }
+ class DoubleWrapsRendersDOM extends React.Component {
+ render() {
+ return
;
+ }
+ }
+
+ it('throws on a DOM node', () => {
+ const wrapper = shallow(
);
+ expect(wrapper.is('div')).to.equal(true);
+
+ expect(() => { wrapper.dive(); }).to.throw(
+ TypeError,
+ 'ShallowWrapper::dive() can not be called on DOM components'
+ );
+ });
+
+ it('throws on a non-component', () => {
+ const wrapper = shallow(
);
+ expect(wrapper.type()).to.equal(null);
+
+ expect(() => { wrapper.dive(); }).to.throw(
+ TypeError,
+ 'ShallowWrapper::dive() can only be called on components'
+ );
+ });
+
+ it('throws on multiple children found', () => {
+ const wrapper = shallow(
).find('div').children();
+ expect(() => { wrapper.dive(); }).to.throw(
+ Error,
+ 'Method “dive” is only meant to be run on a single node. 2 found instead.'
+ );
+ });
+
+ it('dives + shallow-renders when there is one component child', () => {
+ const wrapper = shallow(
);
+ expect(wrapper.is(WrapsRendersDOM)).to.equal(true);
+
+ const underwater = wrapper.dive();
+ expect(underwater.is(RendersDOM)).to.equal(true);
+ });
+ });
});
diff --git a/test/Utils-spec.jsx b/test/Utils-spec.jsx
index 49173eed1..de4d03e0d 100644
--- a/test/Utils-spec.jsx
+++ b/test/Utils-spec.jsx
@@ -10,7 +10,7 @@ import {
childrenToSimplifiedArray,
getNode,
nodeEqual,
- isSimpleSelector,
+ isPseudoClassSelector,
propFromEvent,
SELECTOR,
selectorType,
@@ -209,8 +209,8 @@ describe('Utils', () => {
)).to.equal(false);
expect(nodeEqual(
-
,
-
+
child
,
+
child
,
)).to.equal(false);
});
@@ -221,8 +221,8 @@ describe('Utils', () => {
)).to.equal(false);
expect(nodeEqual(
-
,
-
+
child
,
+
other child
,
)).to.equal(false);
});
@@ -233,7 +233,7 @@ describe('Utils', () => {
)).to.equal(true);
expect(nodeEqual(
-
,
+
, // eslint-disable-line react/no-children-prop
)).to.equal(true);
});
@@ -254,39 +254,43 @@ describe('Utils', () => {
});
- describe('isSimpleSelector', () => {
+ describe('isPseudoClassSelector', () => {
+
describe('prohibited selectors', () => {
- function isComplex(selector) {
+ function isNotPseudo(selector) {
it(selector, () => {
- expect(isSimpleSelector(selector)).to.equal(false);
+ expect(isPseudoClassSelector(selector)).to.equal(false);
});
}
-
- isComplex('.foo .bar');
- isComplex(':visible');
- isComplex('.foo>.bar');
- isComplex('.foo > .bar');
- isComplex('.foo~.bar');
-
+ isNotPseudo('.foo');
+ isNotPseudo('div');
+ isNotPseudo('.foo .bar');
+ isNotPseudo('[hover]');
+ isNotPseudo('[checked=""]');
+ isNotPseudo('[checked=":checked"]');
+ isNotPseudo('[checked=\':checked\']');
+ isNotPseudo('.foo>.bar');
+ isNotPseudo('.foo > .bar');
+ isNotPseudo('.foo~.bar');
+ isNotPseudo('#foo');
});
describe('allowed selectors', () => {
- function isSimple(selector) {
+ function isPseudo(selector) {
it(selector, () => {
- expect(isSimpleSelector(selector)).to.equal(true);
+ expect(isPseudoClassSelector(selector)).to.equal(true);
});
}
-
- isSimple('.foo');
- isSimple('.foo-and-foo');
- isSimple('input[foo="bar"]');
- isSimple('input[foo="bar"][bar="baz"][baz="foo"]');
- isSimple('.FoOaNdFoO');
- isSimple('tag');
- isSimple('.foo.bar');
- isSimple('input.foo');
-
+ isPseudo(':checked');
+ isPseudo(':focus');
+ isPseudo(':hover');
+ isPseudo(':disabled');
+ isPseudo(':any');
+ isPseudo(':last-child');
+ isPseudo(':nth-child(1)');
+ isPseudo('div:checked');
+ isPseudo('[data-foo=":hover"]:hover');
});
});
diff --git a/withDom.js b/withDom.js
index 19b49d36b..383b3e914 100644
--- a/withDom.js
+++ b/withDom.js
@@ -2,13 +2,10 @@ if (!global.document) {
try {
const jsdom = require('jsdom').jsdom; // could throw
- const exposedProperties = ['window', 'navigator', 'document'];
-
global.document = jsdom('');
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
- exposedProperties.push(property);
global[property] = document.defaultView[property];
}
});