jasmine-enzyme
Advanced tools
Comparing version 0.1.0-rc2 to 0.1.0
{ | ||
"name": "jasmine-enzyme", | ||
"version": "0.1.0-rc2", | ||
"version": "0.1.0", | ||
"description": "Jasmine assertions for enzyme", | ||
@@ -54,2 +54,5 @@ "main": "lib/index.js", | ||
"jest": { | ||
"testPathDirs": [ | ||
"<rootDir>/src" | ||
], | ||
"setupTestFrameworkScriptFile": "./src/jest.js", | ||
@@ -56,0 +59,0 @@ "unmockedModulePathPatterns": [ |
# jasmine-enzyme | ||
[![npm version](https://img.shields.io/npm/v/jasmine-enzyme.svg)](https://www.npmjs.com/package/jasmine-enzyme) | ||
![License](https://img.shields.io/npm/l/chai-enzyme.svg) | ||
@@ -20,7 +21,11 @@ | ||
1. [toBePresent()](#tobepresent) | ||
1. [toContain()](#tocontain) | ||
1. [toHaveClassName()](#tohaveclassname) | ||
1. [toHaveHTML()](#tohavehtml) | ||
1. [toHaveRef()](#tohaveref) | ||
1. [toHaveValue()](#tohavevalue) | ||
1. [toContain()](#tocontainreactinstanceobject) | ||
1. [toHaveClassName()](#tohaveclassnameclassnamestring) | ||
1. [toHaveHTML()](#tohavehtmlhtmlstring) | ||
1. [toHaveProp()](#tohaveproppropkeystring-propvalueany) | ||
1. [toHaveRef()](#tohaverefrefnamestring) | ||
1. [toHaveState()](#tohavestatestatekeystring-statevalueany) | ||
1. [toHaveTagName()](#tohavetagnametagnamestring) | ||
1. [toHaveValue()](#tohavevaluevalueany) | ||
1. [toMatch()](#tomatchselectorstring) | ||
1. [Development](#development) | ||
@@ -277,2 +282,34 @@ 1. [Contributing](#contributing) | ||
#### `toHaveProp(propKey:string[, propValue:?any])` | ||
| render | mount | shallow | | ||
| -------|-------|-------- | | ||
| no | yes | yes | | ||
Assert that the given wrapper has the provided propKey and associated value if specified: | ||
```js | ||
function User() { ... } | ||
User.propTypes = { | ||
foo: PropTypes.string, | ||
bar: PropTypes.array, | ||
}; | ||
function Fixture() { | ||
return ( | ||
<div id="root"> | ||
<User foo={'baz'} bar={[1,2,3]} /> | ||
</div> | ||
); | ||
} | ||
const wrapper = mount(<Fixture />); // mount/render/shallow when applicable | ||
expect(wrapper.find(User)).toHaveProp('foo'); | ||
expect(wrapper.find(User)).toHaveProp('foo', 'baz'); | ||
expect(wrapper.find(User)).toHaveProp('bar'); | ||
expect(wrapper.find(User)).toHaveProp('bar', [1,2,3]); | ||
``` | ||
#### `toHaveRef(refName:string)` | ||
@@ -303,2 +340,32 @@ | ||
#### `toHaveState(stateKey:string[, stateValue:?any])` | ||
| render | mount | shallow | | ||
| -------|-------|-------- | | ||
| no | yes | yes | | ||
Assert that the component has the provided stateKey and optional value if specified: | ||
```js | ||
class Fixture extends React.Component { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
foo: false, | ||
}; | ||
} | ||
render() { | ||
return ( | ||
<div /> | ||
); | ||
} | ||
} | ||
const wrapper = mount(<Fixture />); // mount/render/shallow when applicable | ||
expect(wrapper).toHaveState('foo'); | ||
expect(wrapper).toHaveState('foo', false); | ||
``` | ||
#### `toHaveTagName(tagName:string)` | ||
@@ -305,0 +372,0 @@ |
@@ -15,3 +15,5 @@ /** | ||
import toHaveHTML from './assertions/toHaveHTML'; | ||
import toHaveProp from './assertions/toHaveProp'; | ||
import toHaveRef from './assertions/toHaveRef'; | ||
import toHaveState from './assertions/toHaveState'; | ||
import toHaveTagName from './assertions/toHaveTagName'; | ||
@@ -29,3 +31,5 @@ import toHaveValue from './assertions/toHaveValue'; | ||
jasmine.addMatchers(toHaveHTML); | ||
jasmine.addMatchers(toHaveProp); | ||
jasmine.addMatchers(toHaveRef); | ||
jasmine.addMatchers(toHaveState); | ||
jasmine.addMatchers(toHaveTagName); | ||
@@ -32,0 +36,0 @@ jasmine.addMatchers(toHaveValue); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38677
37
833
481