New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

chai-react

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-react - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0-rc1

57

chai-react.js

@@ -6,9 +6,9 @@ (function (chaiReact) {

module.exports = function (chai, utils) {
return chaiReact(chai, utils, require('react'));
return chaiReact(chai, utils, require('react'), require('react-addons-test-utils'));
};
} else if (typeof define === "function" && define.amd) {
// AMD
define(['react'], function (React) {
define(['react', 'react-dom', 'react-addons-test-utils'], function (React, TestUtils) {
return function (chai, utils) {
return chaiReact(chai, utils, React);
return chaiReact(chai, utils, React, TestUtils);
};

@@ -19,8 +19,7 @@ });

chai.use(function (chai, utils) {
return chaiReact(chai, utils, React);
return chaiReact(chai, utils, React, React.addons.TestUtils);
});
}
}(function (chai, utils, React) {
var flag = utils.flag,
TestUtils = React.addons.TestUtils;
}(function (chai, utils, React, TestUtils) {
var flag = utils.flag;

@@ -33,2 +32,22 @@ function inspectify (component) {

function getComponentProp (component, prop) {
if (TestUtils.isDOMComponent(component)) {
if (prop === 'className') {
return component.className;
} else {
return component.getAttribute(prop);
}
} else {
return component.props[prop];
}
}
function componentHasProp (component, prop) {
if (TestUtils.isDOMComponent(component)) {
return component.hasAttribute(prop);
} else {
return component.props && prop in component.props;
}
}
chai.Assertion.addMethod('state', function (name, value) {

@@ -65,3 +84,3 @@ var component = flag(this, 'object'),

chai.Assertion.addMethod('prop', function (name, value) {
var props, actual,
var actual,
component = flag(this, 'object');

@@ -71,4 +90,3 @@

props = component.props || {};
actual = props[name];
actual = getComponentProp(component, name);

@@ -107,4 +125,6 @@ inspectify(component);

components = TestUtils.findAllInRenderedTree(component, function (comp) {
var prop;
if (value !== undefined) {
var prop = comp.props[name];
prop = getComponentProp(comp, name);

@@ -120,3 +140,3 @@ switch (match) {

return comp.props && name in comp.props;
return componentHasProp(comp, name);
});

@@ -176,8 +196,13 @@

chai.Assertion.addMethod('componentWithTag', function (tag) {
var component = flag(this, 'object');
var found,
component = flag(this, 'object');
new chai.Assertion(component).is.a.component;
inspectify(component);
if (TestUtils.isDOMComponent(component)) {
found = component.tagName.toLowerCase() === tag.toLowerCase();
} else {
new chai.Assertion(component).is.a.component;
inspectify(component);
var found = TestUtils.findRenderedDOMComponentWithTag(component, tag);
found = TestUtils.findRenderedDOMComponentWithTag(component, tag);
}

@@ -184,0 +209,0 @@ flag(this, 'object', found);

@@ -12,3 +12,3 @@ {

],
"version": "2.0.1",
"version": "3.0.0-rc1",
"repository": {

@@ -35,4 +35,6 @@ "type": "git",

"mocha-phantomjs": "3",
"react": "^0.13.0"
"react": "^0.14.0",
"react-addons-test-utils": "^0.14.0",
"react-dom": "^0.14.0"
}
}
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