Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arnthor3 committed Dec 11, 2017
1 parent e9377a0 commit b70a3fc
Show file tree
Hide file tree
Showing 9 changed files with 9,677 additions and 77 deletions.
12 changes: 3 additions & 9 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
"presets": ["stage-0", "es2015", "react"],
"plugins": ["transform-class-properties", "transform-decorators-legacy" ],
"env": {
"development": {
"sourceMaps": true,
"presets": ["react-hmre"]
}
}
}
"presets": ["es2015", "react", "stage-0"],
"plugins": [ "transform-class-properties"]
}
17 changes: 12 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
"browser": true,
"es6": true
},
"globals": {
"describe": true,
"it": true,
"expect": true
},
"parser": "babel-eslint",
"plugins": ["react"],
"extends": ["eslint:recommended", "airbnb"],
//this is to get the import export thing out of the mix
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 7,
"ecmaFeatures": {
"jsx": true,
"experimentalObjectRestSpread": true
}
},
"globals": {
"beforeEach": true,
"describe": true,
"expect": true,
"it": true,
"React": true,
"xdescribe": true,
"xit": true
},
"rules": {
"no-unused-vars" : 0,
"no-console" : 0
Expand Down
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
coverage/
coverage/
examples/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ after_script:
- "npm run coverage"
- "npm install coveralls && cat ./coverage/lcov.info | coveralls"
env:
- REACT=15
- REACT=16
39 changes: 10 additions & 29 deletions __test__/delayRender.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React from 'react';
import { mount, shallow } from 'enzyme';
import { mount, shallow, configure } from 'enzyme';
import sinon from 'sinon';

import DelayRender from '../src/';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

describe('DelayRender', () => {
it('should render one component', () => {
Expand All @@ -13,17 +17,14 @@ describe('DelayRender', () => {
expect(dom.find('h1').length).toBe(1);
});
it('should delay one component', (done) => {
const MyElement = () => (
<h1 style={{ color: 'red' }}>TEST</h1>
);
const Test = DelayRender({ delay: 500 })(MyElement);

const Test = DelayRender({ delay: 50 })(() => <span>TEST</span>);
const dom = mount(<Test />);
expect(dom.find('h1').length).toBe(0);
expect(dom.find('span').length).toBe(0);
const ren = sinon.spy(Test.prototype, 'render');
setTimeout(() => {
expect(dom.find('h1').length).toBe(1);
const h1 = dom.find('h1').childAt(0);
done();
}, 500);
}, 700);
});
it('should callback when rendering', (done) => {
const MyElement = () => (
Expand Down Expand Up @@ -52,25 +53,5 @@ describe('DelayRender', () => {
}, 200);
});

it('should be able to set delay on children', () => {
const render = () => {
return 'test';
}
@DelayRender({ delay: 400, onRender: render})
class Test extends React.Component {
render() {
return (
<div>
<p delay={100}>This</p>
<p delay={150}>Is</p>
<p delay={200}>A</p>
<p delay={250}>TEST</p>
</div>
);
}
}
const dom = mount(<Test />);

});

});
Loading

0 comments on commit b70a3fc

Please sign in to comment.