{"_id":"@allenluce/chai-enzyme","_rev":"1-c5d740b2740fe48bfcc77f5093b6f217","name":"@allenluce/chai-enzyme","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@allenluce/chai-enzyme","version":"1.0.1","description":"Chai.js assertions for enzyme","homepage":"https://github.com/producthunt/chai-enzyme","author":{"name":"Veselin Todorov","email":"hi@vesln.com","url":"https://github.com/vesln"},"repository":{"type":"git","url":"git://github.com/producthunt/chai-enzyme.git"},"bugs":{"url":"https://github.com/producthunt/chai-enzyme/issues"},"main":"build/index.js","scripts":{"prepublish":"npm run clean && npm run build","build":"babel src --out-dir build","clean":"rimraf build","test:lint":"standard --verbose | snazzy","test:unit":"cross-env NODE_ENV=test mocha test/**/*.test.js","test:watch":"npm run test:unit -- --watch","test":"npm run test:lint && npm run test:unit"},"peerDependencies":{"chai":"^3.0.0 || ^4.0.0","cheerio":"0.19.x || 0.20.x || 0.22.x || ^1.0.0-0","enzyme":"^2.7.0 || ^3.0.0","react":"^0.14.0 || ^15.0.0-0 || ^16.0.0-0 || ^17.0.0-0","react-dom":"^0.14.0 || ^15.0.0-0 || ^16.0.0-0 || ^17.0.0-0"},"keywords":["javascript","shallow rendering","shallowRender","test","reactjs","react","flux","testing","test utils","assertion helpers","tdd","mocha","chai","chaijs","enzyme"],"license":"MIT","devDependencies":{"@babel/cli":"^7.17.6","@babel/eslint-parser":"^7.17.0","@babel/preset-env":"^7.16.11","@babel/preset-react":"^7.16.7","@babel/register":"^7.17.0","@wojtekmaj/enzyme-adapter-react-17":"^0.6.6","chai":"^4.3.6","cross-env":"^7.0.3","enzyme":"^3.11.0","jsdom":"^19.0.0","mocha":"^9.2.1","prop-types":"^15.8.1","react":"^17.0.2","react-dom":"^17.0.2","react-test-renderer":"^17.0.2","rimraf":"^3.0.2","snazzy":"^9.0.0","standard":"^16.0.4"},"standard":{"parser":"@babel/eslint-parser","global":["describe","it","before","beforeEach","after","afterEach","React","expect","createTest","isEnzyme3"]},"dependencies":{"html":"^1.0.0"},"directories":{"test":"test"},"gitHead":"28387958fed3031c80cb199bf92b10a394234a82","_id":"@allenluce/chai-enzyme@1.0.1","_nodeVersion":"17.4.0","_npmVersion":"8.3.1","dist":{"integrity":"sha512-3y6oXQj3SwLh8PLftCeePCUYJY4acTxK9iLnHkU2/l2aZRjCAwwNccAFyXxeiVX0ZSTaWdRlgP6XapF186kVQA==","shasum":"5284f2417265059fce646aa1242ec9090813627d","tarball":"https://registry.npmjs.org/@allenluce/chai-enzyme/-/chai-enzyme-1.0.1.tgz","fileCount":97,"unpackedSize":155496,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiJUrYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpGzhAAkb+OYkfdrZMiEoiZVUXgKx29ufRoJAll9mjmN8cmQ0W/UPZe\r\nBClHRpC+zt1S0SZpwgtpUA62zX9J5/pD15aFOWBjwjtWMOAr14BC7K/xVsWK\r\nU2EFhmkh7X9OSON6icC+LiQOjK0AI8RFVV5mtshmaqEFdlODSdXPNqriHO1P\r\n04u4KgnrqBfhBoh6dk1OVjO1Ij2926+lv/B2ASRZGe5kf8ywTL162HERmUXF\r\nuy9OtNtDGCZpZo4na2BijbGEbuUG+BmqHUwiOKf3S03+kQrr09tcTR0YY4vn\r\nhQYdJOfMhMHwwFtuGYAv1OwFTtGdII4PbmevGUJPO8GXY879aBGhn9qrDZOt\r\nRZLOyT6jcsAjW7y3+t97JrBV0E9GR/V1ww+wZ1fMC3qWMLoVBWWCw/3m0l8O\r\nl8kfal9JfYKelIfrBDe5rOKkdifgPbAi/T8sLdY/VhMNB6t7dsByyawn5JuH\r\nZNGFB7RALfpgvYTqMTKowtblUO7/czQXXqgeFLNgClx9vwXUhiR7i/wrt8HG\r\n1KcXQLTezzJo8fR/o7PwvcdUcuJRwKlwXLS249r4MHcSVuYuvp/zy6p3yerk\r\nQ8QyA4scurm+9SIyllFKG+TVUvi2LNWTVg5hPVLtjKbr3Vq0Q3xn9OiPcS28\r\n9DX4j8wLIPohKs5sKRIa+6zURpkGo0hwSOs=\r\n=ITJW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG7WMlikFq6Mk4BkErr1TYR0WypFbx1RvlbQEL25UMTJAiA4xqfod51isYbfu/Ks8we5xe8h/v+/MaxVpNEySYwBsQ=="}]},"_npmUser":{"name":"allenluce","email":"allen@npm.con.com"},"maintainers":[{"name":"allenluce","email":"allen@npm.con.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chai-enzyme_1.0.1_1646611159920_0.9968021854320774"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-06T23:59:19.858Z","1.0.1":"2022-03-06T23:59:20.082Z","modified":"2022-04-04T13:31:52.769Z"},"maintainers":[{"name":"allenluce","email":"allen@npm.con.com"}],"description":"Chai.js assertions for enzyme","homepage":"https://github.com/producthunt/chai-enzyme","keywords":["javascript","shallow rendering","shallowRender","test","reactjs","react","flux","testing","test utils","assertion helpers","tdd","mocha","chai","chaijs","enzyme"],"repository":{"type":"git","url":"git://github.com/producthunt/chai-enzyme.git"},"author":{"name":"Veselin Todorov","email":"hi@vesln.com","url":"https://github.com/vesln"},"bugs":{"url":"https://github.com/producthunt/chai-enzyme/issues"},"license":"MIT","readme":"# chai-enzyme\n\n[![npm version](https://img.shields.io/npm/v/chai-enzyme.svg)](https://www.npmjs.com/package/chai-enzyme) [![License](https://img.shields.io/npm/l/chai-enzyme.svg)](https://www.npmjs.com/package/chai-enzyme) [![Build Status](https://travis-ci.org/producthunt/chai-enzyme.svg)](https://travis-ci.org/producthunt/chai-enzyme)\n\n[Chai.js](https://github.com/chaijs/chai) assertions for [enzyme](https://github.com/airbnb/enzyme/).\n\n## Table of Contents\n\n  1. [Installation](#installation)\n  1. [Setup](#setup)\n  1. [Debug output in assertion exceptions](#debug-output-in-assertion-exceptions)\n  1. [Assertions](#assertions)\n    1. [`checked()`](#checked)\n    1. [`className(str)`](#classnamestr)\n    1. [`contain(nodeOrNodes)`](#containnodeornodes)\n    1. [`containMatchingElement(node)`](#containmatchingelementnode)\n    1. [`descendants(selector)`](#descendantsselector)\n      1. [`exactly()`](#exactly)\n    1. [`disabled()`](#disabled)\n    1. [`blank()`](#blank)\n    1. [`present()`](#present)\n    1. [`html(str)`](#htmlstr)\n    1. [`id(str)`](#idstr)\n    1. [`match(selector)`](#matchselector)\n    1. [`ref(key)`](#refkey)\n    1. [`selected()`](#selected)\n    1. [`tagName(str)`](#tagnamestr)\n    1. [`text(str)`](#textstr)\n    1. [`type(func)`](#typefunc)\n    1. [`value(str)`](#valuestr)\n    1. [`attr(key, [val])`](#attrkey-val)\n    1. [`data(key, [val])`](#datakey-val)\n    1. [`style(key, [val])`](#stylekey-val)\n    1. [`state(key, [val])`](#statekey-val)\n    1. [`prop(key, [val])`](#propkey-val)\n    1. [`props(key, [val])`](#propskey-val)\n  1. [Development](#development)\n  1. [Contributing](#contributing)\n  1. [License](#license)\n\n## Installation\n\n`@allenluce/chai-enzyme` depends on:\n\n```js\n\"peerDependencies\": {\n  \"chai\": \"^3.0.0 || ^4.0.0\",\n  \"cheerio\": \"0.19.x || 0.20.x || 0.22.x || ^1.0.0-0\",\n  \"enzyme\": \"^2.7.0 || ^3.0.0\",\n  \"react\": \"^0.14.0 || ^15.0.0-0 || ^16.0.0-0\",\n  \"react-dom\": \"^0.14.0 || ^15.0.0-0 || ^16.0.0-0\"\n}\n```\n\n`cheerio` is already a dependency of `enzyme`, so most probably you will not have\nto install it manually\n\n```\n$ npm install @allenluce/chai-enzyme --save-dev\n```\n\n## Setup\n\n```js\nimport chai from 'chai'\nimport chaiEnzyme from '@allenluce/chai-enzyme'\n\nchai.use(chaiEnzyme()) // Note the invocation at the end\n```\n\n## Debug output in assertion exceptions\n\nYou can also provide a custom debug function that can print useful information\nabout the `wrapper` that you are using.\n\nThe default one that @allenluce/chai-enzyme comes with, will pretty print the HTML of the\nwrapper under test.\n\n```shell\n  1) #text (text) (shallow): passes when the actual matches the expected:\n     AssertionError: expected <Fixture /> to have text 'Test test', but it has 'Test'\n\n     ---------- this is where the debug output starts ----------\n\n     HTML:\n\n     <span id=\"child\">Test</span>\n\n     ---------- this is where the debug output ends ----------\n```\n\nHere is how you can implement and configure one for yourself:\n\n```js\nfunction myAwesomeDebug (wrapper) {\n  let html = wrapper.html()\n  // do something cool with the html\n  return html\n}\n\nchai.use(chaiEnzyme(myAwesomeDebug))\n```\n\n## Assertions\n\nIt's important to know that all assertions are registered with Chai's `overwrite*`\nmethods and therefore this plugin can work next to other Chai.js plugins that have\nsimilar assertions, such as [chai-jquery](https://github.com/chaijs/chai-jquery).\n\nAt the beginning of each assertion, we verify if the provided object is a\n`ShallowWrapper`, `ReactWrapper` or a `cheerio` object and if not we delegate\nto the next assertion that responds to the given method.\n\nNote that not all assertions work with every rendering strategy.\n\nIf you are wondering what rendering mechanism to use when, refer to [enzyme's\ndocumentation](https://github.com/airbnb/enzyme).\n\n#### `checked()`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the given wrapper is checked:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <input id='checked' defaultChecked />\n        <input id='not' defaultChecked={false} />\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('#checked')).to.be.checked()\nexpect(wrapper.find('#not')).to.not.be.checked()\n```\n\n#### `className(str)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper has a given class:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div className='root top'>\n        <span className='child bottom'>test</span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('span')).to.have.className('child')\nexpect(wrapper.find('span')).to.not.have.className('root')\n```\n\n#### `contain(nodeOrNodes)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| no     | yes   | yes     |\n\n\nAssert that the wrapper contains a given node or array of nodes:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\nimport PropTypes from 'prop-types';\n\nclass User extends React.Component {\n  render () {\n    return (\n      <span>User {this.props.index}</span>\n    )\n  }\n}\n\nUser.propTypes = {\n  index: PropTypes.number.isRequired\n}\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <ul>\n          <li><User index={1} /></li>\n          <li>\n            <User index={2} />\n            <User index={3} />\n          </li>\n        </ul>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.contain(<User index={1} />)\nexpect(wrapper).to.contain([<User index={2} />, <User index={3} />])\nexpect(wrapper).to.not.contain(<User index={3} />)\n```\n\n#### `containMatchingElement(node)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| no     | yes   | yes     |\n\n\nAssert that the wrapper contains a matching given node:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\nimport PropTypes from 'prop-types';\n\nclass User extends React.Component {\n  render () {\n    return (\n      <span>User {this.props.index} {this.props.name}</span>\n    )\n  }\n}\n\nUser.propTypes = {\n  index: PropTypes.number,\n  name: PropTypes.string.isRequired\n}\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <ul>\n          <li><User index={1} name='John' /></li>\n          <li><User index={2} name='Doe' /></li>\n        </ul>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.containMatchingElement(<User name='John' />)\nexpect(wrapper).to.not.containMatchingElement(<User name='Conor' />)\n```\n\n#### `descendants(selector)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper contains a descendant matching the given selector:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass User extends React.Component {\n  render () {\n    return (\n      <span>User</span>\n    )\n  }\n}\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='root'>\n        <User />\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.have.descendants('#root')\nexpect(wrapper).to.have.descendants(User)\n\nexpect(wrapper).to.not.have.descendants('#root1')\n```\n\n#### `exactly()`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper contains an exact amount of descendants matching the given selector:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='root'>\n        <span id='child'>\n          <span class='item'></span>\n          <span class='item'></span>\n        </span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.have.exactly(2).descendants('.item')\n```\n\n#### `disabled()`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the given wrapper is disabled:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <input id='disabled' disabled />\n        <input id='not' />\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('#disabled')).to.be.disabled()\nexpect(wrapper.find('#not')).to.not.be.disabled()\n```\n\n#### `blank()`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the given wrapper is empty:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='parent'>\n        <div id='child'>\n        </div>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('#child')).to.be.blank()\nexpect(wrapper.find('#parent')).to.not.be.blank()\n\nexpect(wrapper.find('#child')).to.be.empty // an alias\nexpect(wrapper.find('#parent')).to.not.be.empty // an alias\n\nclass NullFixture extends React.Component {\n  render () {\n    return null\n  }\n}\n\nconst nullWrapper = mount(<NullFixture />) // mount/render/shallow when applicable\n\nexpect(nullWrapper).to.be.blank()\nexpect(nullWrapper).to.be.empty // an alias\n```\n\n#### `present()`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the given wrapper exists:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='parent'></div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('#parent')).to.be.present()\nexpect(wrapper.find('#parent')).to.exist // an alias\n\nclass NullFixture extends React.Component {\n  render () {\n    return null\n  }\n}\n\nconst nullWrapper = mount(<NullFixture />) // mount/render/shallow when applicable\n\nexpect(nullWrapper).to.be.present()\nexpect(nullWrapper).to.exist // an alias\n```\n\n#### `html(str)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper has given html:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='root'>\n        <span id='child'>Test</span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('#child')).to.have.html('<span id=\"child\">Test</span>')\n\nexpect(wrapper.find('#child')).to.not.have.html('<span id=\"child\">Test 1</span>')\n\nexpect(wrapper.find('#child')).to.have.html().match(/Test/)\n```\n\n#### `id(str)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper has given ID attribute:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='root'>\n        <span id='child'>test</span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.have.id('root')\nexpect(wrapper).to.not.have.id('child')\n```\n\n#### `match(selector)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper matches given selector:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='root'>\n        <span id='child'>test</span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('span')).to.match('#child')\nexpect(wrapper.find('#root')).to.not.match('#child')\n```\n\n#### `ref(key)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| no     | yes   | no      |\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <input ref='test' />\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.have.ref('test')\nexpect(wrapper).to.have.ref('random')\n```\n\n#### `selected()`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | no      |\n\n\nAssert that the given wrapper is selected:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <select defaultValue='test1'>\n        <option id='test1' value='test1'>Test 1</option>\n        <option id='test2' value='test2'>Test 1</option>\n      </select>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('#test1')).to.be.selected()\nexpect(wrapper.find('#test2')).to.not.be.selected()\n```\n\n#### `tagName(str)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the given wrapper has the tag name:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <span />\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.have.tagName('div')\nexpect(wrapper.find('span')).to.have.tagName('span')\n\nexpect(wrapper).to.not.have.tagName('a')\nexpect(wrapper.find('span')).to.not.have.tagName('a')\n```\n\n#### `text(str)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the given wrapper has the supplied text:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='root'>\n        <span id='child'>Test</span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('#child')).to.have.text('Test')\n\nexpect(wrapper.find('#child')).to.contain.text('Te')\nexpect(wrapper.find('#child')).to.include.text('Te') // include is an alias of contain\n\nexpect(wrapper.find('#child')).to.not.have.text('Other text')\nexpect(wrapper.find('#child')).to.not.include.text('Other text') // include is an alias of contain\n\nexpect(wrapper.find('#child')).to.have.text().match(/Test/)\n```\n\n#### `type(func)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| no     | yes   | yes     |\n\n\nAssert that the given wrapper has a given type:\n\n```js\nimport React from 'react'\nimport {shallow} from 'enzyme'\n\nclass Foo extends React.Component {\n  render () {\n    return (\n      <div>Foo</div>\n    )\n  }\n}\n\nclass Bar extends React.Component {\n  render () {\n    return (\n      <div>Bar</div>\n    )\n  }\n}\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <Foo />\n    )\n  }\n}\n\nconst shallowWrapper = shallow(<Fixture />)\nconst mountWrapper = mount(<Fixture />)\n\nexpect(shallowWrapper).to.have.type(Foo)\nexpect(shallowWrapper).to.not.have.type(Bar)\n\nexpect(mountWrapper).to.have.type(Fixture)\nexpect(mountWrapper).to.not.have.type(Bar)\n```\n\n#### `value(str)`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the given wrapper has given value:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <input defaultValue='test' />\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('input')).to.have.value('test')\nexpect(wrapper.find('input')).to.not.have.value('other')\n```\n\n#### `attr(key, [val])`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper has given attribute [with value]:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div id='root'>\n        <span id='child'>test</span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find('span')).to.have.attr('id')\nexpect(wrapper).to.not.have.attr('disabled')\n\nexpect(wrapper).to.have.attr('id', 'root')\nexpect(wrapper).to.not.have.attr('id', 'invalid')\n\nexpect(wrapper).to.have.attr('id').equal('root')\n```\n\n#### `data(key, [val])`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper has a given data attribute [with value]:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div data-name='root'>\n        <span data-name='child'>test</span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.have.data('name')\nexpect(wrapper).to.not.have.data('random')\n\nexpect(wrapper).to.have.data('name', 'root')\nexpect(wrapper).to.not.have.data('name', 'invalid')\n\nexpect(wrapper).to.have.data('name').equal('root')\n```\n\n#### `style(key, [val])`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| yes    | yes   | yes     |\n\n\nAssert that the wrapper has given style:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div style={{ border: 1 }}>\n        <span style={{ color: 'red' }}>test</span>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.have.style('border')\nexpect(wrapper).to.not.have.style('color')\nexpect(wrapper).to.have.style('margin-top') // do not use camelCase keys as you would do in your React component\n\nexpect(wrapper).to.have.style('border', '1px')\nexpect(wrapper).to.not.have.style('border', '2px')\n\nexpect(wrapper).to.have.style('border').equal('1px')\n```\n\n#### `state(key, [val])`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| no     | yes   | yes     |\n\n\nAssert that the wrapper has given state [with value]:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\n\nclass Fixture extends React.Component {\n  constructor () {\n    super()\n    this.state = { foo: 'bar' }\n  }\n\n  render () {\n    return (\n      <div id='root'>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper).to.have.state('foo')\nexpect(wrapper).to.not.have.state('bar')\n\n\nexpect(wrapper).to.have.state('foo', 'bar')\nexpect(wrapper).to.not.have.state('foo', 'baz')\n\nexpect(wrapper).to.have.state('foo').equal('bar')\n```\n\n\n#### `prop(key, [val])`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| no     | yes   | yes     |\n\nAssert that the wrapper has given prop [with value]:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\nimport PropTypes from 'prop-types';\n\nclass User extends React.Component {\n  render () {\n    return (\n      <span>User {this.props.index}</span>\n    )\n  }\n}\n\nUser.propTypes = {\n  index: PropTypes.number.isRequired\n}\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <ul>\n          <li><User index={1} user={{name: 'Jane'}} /></li>\n          <li><User index={2} /></li>\n        </ul>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find(User).first()).to.have.prop('index')\nexpect(wrapper.find(User).first()).to.not.have.prop('invalid')\n\n\nexpect(wrapper.find(User).first()).to.have.prop('index', 1)\nexpect(wrapper.find(User).first()).to.not.have.prop('index', 2)\n\nexpect(wrapper.find(User).first()).to.have.prop('index').equal(1)\nexpect(wrapper.find(User).first()).to.have.prop('user').deep.equal({name: 'Jane'})\n```\n\n#### `props(key, [val])`\n\n| render | mount | shallow |\n| -------|-------|-------- |\n| no     | yes   | yes     |\n\nAssert that the wrapper has given set of props [with values]:\n\n```js\nimport React from 'react'\nimport {mount, render, shallow} from 'enzyme'\nimport PropTypes from 'prop-types';\n\nclass User extends React.Component {\n  render () {\n    return (\n      <span>User {this.props.index}</span>\n    )\n  }\n}\n\nUser.propTypes = {\n  index: PropTypes.number.isRequired\n}\n\nclass Fixture extends React.Component {\n  render () {\n    return (\n      <div>\n        <ul>\n          <li><User index={1} user={{name: 'Jane'}} /></li>\n          <li><User index={2} /></li>\n        </ul>\n      </div>\n    )\n  }\n}\n\nconst wrapper = mount(<Fixture />) // mount/render/shallow when applicable\n\nexpect(wrapper.find(User).first()).to.have.props([ 'index', 'user' ])\nexpect(wrapper.find(User).first()).to.not.have.props([ 'invalid' ])\n\n\nexpect(wrapper.find(User).first()).to.have.props({ index: 1 })\nexpect(wrapper.find(User).first()).to.not.have.props({ index: 2 })\n\nexpect(wrapper.find(User).first()).to.have.props([ 'index', 'user' ]).deep.equal([ 1, { name: 'Jane' } ])\n```\n\n## Development\n\n#### Setup\n\n```shell\n$ git clone <this repo>\n$ cd chai-enzyme\n$ npm install\n```\n\n#### Tests\n\nLinters:\n\n```shell\n$ npm run test:lint\n```\n\nTests:\n\n```shell\n$ npm run test:unit\n```\n\nAll:\n\n```shell\n$ npm test\n```\n\n## Contributing\n\nWe want to make this assertion library as robust and complete as possible. If\nyou think that there are missing features/assertions, please open a GitHub issue or even\nbetter - a PR.\n\nBug reports and pull requests are welcome on GitHub. This project is intended to be a\nsafe, welcoming space for collaboration, and contributors are expected to adhere\nto the [Contributor Covenant](http://contributor-covenant.org/) code of conduct.\n\n## License\n\n[![Product Hunt](http://i.imgur.com/dtAr7wC.png)](https://www.producthunt.com)\n\n```\n _________________\n< The MIT License >\n -----------------\n        \\   ^__^\n         \\  (oo)\\_______\n            (__)\\       )\\/\\\n                ||----w |\n                ||     ||\n```\n","readmeFilename":"README.md"}