From b88114ba2c7e705b79729af2d2846f2230447e80 Mon Sep 17 00:00:00 2001 From: Brandon Dail Date: Tue, 26 Sep 2017 13:32:48 -0700 Subject: [PATCH 01/12] Test attribute value selectors with public API --- .../test/RSTTraversal-spec.jsx | 2 +- .../enzyme-test-suite/test/selector-spec.jsx | 76 +++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/packages/enzyme-test-suite/test/RSTTraversal-spec.jsx b/packages/enzyme-test-suite/test/RSTTraversal-spec.jsx index 1d37dcc14..d15799ac8 100644 --- a/packages/enzyme-test-suite/test/RSTTraversal-spec.jsx +++ b/packages/enzyme-test-suite/test/RSTTraversal-spec.jsx @@ -4,11 +4,11 @@ import { expect } from 'chai'; import { elementToTree } from 'enzyme-adapter-utils'; import { hasClassName, - nodeHasProperty, treeForEach, treeFilter, pathToNode, getTextFromNode, + nodeHasProperty } from 'enzyme/build/RSTTraversal'; import './_helpers/setupAdapters'; diff --git a/packages/enzyme-test-suite/test/selector-spec.jsx b/packages/enzyme-test-suite/test/selector-spec.jsx index 25b31f7ef..3b9c131e1 100644 --- a/packages/enzyme-test-suite/test/selector-spec.jsx +++ b/packages/enzyme-test-suite/test/selector-spec.jsx @@ -21,8 +21,16 @@ const tests = [ }, ]; +let expectAttributeMatch; + describe('selectors', () => { tests.forEach(({ describeMethod, name, renderMethod }) => { + before(() => { + expectAttributeMatch = (element, selector, expected) => { + const wrapper = renderMethod(element); + expect(wrapper.is(selector)).to.equal(expected); + }; + }); describeMethod(name, () => { it('simple descendent', () => { const wrapper = renderMethod(( @@ -350,6 +358,74 @@ describe('selectors', () => { expect(wrapper.find('Wrapped(Foo)')).to.have.lengthOf(1); expect(wrapper.find('Wrapped(Twice(Bar))')).to.have.lengthOf(1); }); + + it('should parse booleans', () => { + expectAttributeMatch(