Skip to content

Commit

Permalink
[Tests] fix linter/test scripts; move files with JSX to .jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 6, 2016
1 parent 91cb419 commit b75b32a
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Expand Up @@ -5,6 +5,9 @@
"node": true,
"mocha": true
},
"ecmaFeatures": {
"jsx": true
},
"rules": {
"id-length": 0,
"new-cap": [2, { "capIsNewExceptions": ["AND"] }],
Expand Down
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -10,13 +10,13 @@
"pretest": "npm run lint",
"version": "npm run build",
"clean": "rimraf build",
"lint": "eslint src/** test/**",
"lint": "eslint --ext js,jsx src test",
"check": "npm run lint && npm run test:all",
"build": "babel src --out-dir build",
"test": "npm run test:only",
"test:only": "mocha --require withDom.js --compilers js:babel-core/register --recursive test/*.js --reporter dot",
"test:single": "mocha --require withDom.js --compilers js:babel-core/register --watch --reporter dot",
"test:watch": "mocha --require withDom.js --compilers js:babel-core/register --recursive test/*.js --watch --reporter dot",
"test:only": "mocha --recursive test --reporter dot",
"test:single": "mocha --watch --reporter dot",
"test:watch": "mocha --recursive test --watch --reporter dot",
"test:env": "sh ./example-test.sh",
"test:all": "npm run react:13 && npm run test:only && npm run react:14 && npm run test:only && npm run react:15 && npm run test:only",
"react:clean": "rimraf node_modules/react node_modules/react-dom node_modules/react-addons-test-utils",
Expand All @@ -28,7 +28,7 @@
"docs:build": "npm run docs:prepare && gitbook build",
"docs:watch": "npm run docs:prepare && gitbook serve",
"docs:publish": "npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git fetch git@github.com:airbnb/enzyme.git gh-pages && git checkout -b gh-pages && git add . && git commit -am 'update book' && git push git@github.com:airbnb/enzyme.git gh-pages --force",
"travis": "babel-node ./node_modules/.bin/istanbul cover --report html _mocha -- --require withDom.js test --recursive"
"travis": "babel-node ./node_modules/.bin/istanbul cover --report html _mocha -- test --recursive"
},
"repository": {
"type": "git",
Expand Down
9 changes: 5 additions & 4 deletions src/Debug.js
@@ -1,3 +1,8 @@
import without from 'lodash/without';
import escape from 'lodash/escape';
import compact from 'lodash/compact';
import objectValues from 'object.values';

import {
childrenOfNode,
} from './ShallowTraversal';
Expand All @@ -13,11 +18,7 @@ import {
internalInstance,
propsOfNode,
} from './Utils';
import without from 'lodash/without';
import escape from 'lodash/escape';
import compact from 'lodash/compact';
import { REACT013 } from './version';
import objectValues from 'object.values';

export function typeName(node) {
return typeof node.type === 'function'
Expand Down
4 changes: 2 additions & 2 deletions src/MountedTraversal.js
Expand Up @@ -104,7 +104,7 @@ export function instHasProperty(inst, propKey, stringifiedPropValue) {
return nodePropValue === propValue;
}

return nodeProps.hasOwnProperty(propKey);
return Object.prototype.hasOwnProperty.call(nodeProps, propKey);
}

// called with private inst
Expand Down Expand Up @@ -185,7 +185,7 @@ export function pathToNode(node, root) {
// leaf node. if it isn't the node we are looking for, we pop.
path.pop();
}
queue.push.apply(queue, children);
queue.push(...children);
}

return null;
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions test/.eslintrc
Expand Up @@ -7,5 +7,8 @@
"react/prefer-es6-class": 0,
"react/prefer-stateless-function": 0,
"react/prop-types": 0,
"import/no-extraneous-dependencies": [2, {
"devDependencies": true
}],
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 11 additions & 8 deletions test/Utils-spec.js → test/Utils-spec.jsx
@@ -1,7 +1,10 @@
import { describeWithDOM, describeIf } from './_helpers.js';
/* globals window */

import React from 'react';
import { expect } from 'chai';
import { mount } from '../src/';

import { describeWithDOM, describeIf } from './_helpers';
import { mount } from '../src';
import {
coercePropValue,
getNode,
Expand Down Expand Up @@ -143,40 +146,40 @@ describe('Utils', () => {
it('should not match not equal nodes', () => {
expect(nodeEqual(
<div>child</div>,
<div></div>
<div />
)).to.equal(false);

expect(nodeEqual(
<div></div>,
<div />,
<div>child</div>
)).to.equal(false);
});

it('should skip null children', () => {
expect(nodeEqual(
<div>{null}</div>,
<div></div>
<div />
)).to.equal(true);
});

it('should skip undefined children', () => {
expect(nodeEqual(
<div>{undefined}</div>,
<div></div>
<div />
)).to.equal(true);
});

it('should skip empty children', () => {
expect(nodeEqual(
<div>{[]}</div>,
<div></div>
<div />
)).to.equal(true);
});

it('should skip array of null children', () => {
expect(nodeEqual(
<div>{[null, null, null]}</div>,
<div></div>
<div />
)).to.equal(true);
});

Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions test/mocha.opts
@@ -0,0 +1,3 @@
--require withDom.js
--compilers js:babel-core/register,jsx:babel-core/register
--extensions js,jsx

0 comments on commit b75b32a

Please sign in to comment.