Socket
Socket
Sign inDemoInstall

jasmine-enzyme

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-enzyme - npm Package Compare versions

Comparing version 0.1.0-rc2 to 0.1.0

src/assertions/__tests__/toHaveProp--tests.js

5

package.json
{
"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": [

77

README.md
# 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);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc