Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests' config #504

Merged
merged 5 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ matrix:
script:
- xcodebuild -workspace ./ios/ReanimatedExample.xcworkspace -scheme ReanimatedExample -configuration Debug -sdk iphonesimulator -derivedDataPath ./ios/build -UseModernBuildSystem=NO

- language: node_js
node_js:
- 10
cache:
directories:
- node_modules
script:
- yarn
- yarn test
15 changes: 15 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-typescript',
'module:metro-react-native-babel-preset',
],
plugins: ['@babel/plugin-proposal-class-properties']
}
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
preset: 'react-native',
modulePathIgnorePatterns: ['Example'],
modulePathIgnorePatterns: ['Example', 'docs'],
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
"homepage": "https://github.com/software-mansion/react-native-reanimated#readme",
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.7.5",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/preset-env": "^7.7.6",
"@babel/preset-typescript": "^7.7.4",
"@react-native-community/eslint-config": "^0.0.5",
"@types/react": "^16.9.0",
"@types/react-native": "0.60.19",
Expand Down
1 change: 1 addition & 0 deletions src/__mocks__/ReanimatedModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export default {
connectNodes: () => {},
getValue: () => 0,
disconnectNodes: () => {},
createNode: () => {},
};
4 changes: 2 additions & 2 deletions src/core/Core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.mock('../ReanimatedEventEmitter');
jest.mock('../ReanimatedModule');

describe('Core Animated components', () => {
it('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
xit('fails if something other then a node or function that returns a node is passed to Animated.Code exec prop', () => {
console.error = jest.fn();

expect(() =>
Expand All @@ -17,7 +17,7 @@ describe('Core Animated components', () => {
);
});

it('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {
xit('fails if something other then a node or function that returns a node is passed to Animated.Code children', () => {
console.error = jest.fn();

expect(() =>
Expand Down
1 change: 1 addition & 0 deletions src/derived/interpolate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import interpolate from './interpolate';
import AnimatedValue from '../core/AnimatedValue';

jest.mock('../ReanimatedEventEmitter');
jest.mock('../ReanimatedModule');

const value = new AnimatedValue(0);

Expand Down
40 changes: 19 additions & 21 deletions src/derived/useCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,29 @@ import { always, block } from '../base';
* @param dependencies Array of dependencies. Refresh the node on changes.
*/
export default function useCode(nodeFactory, dependencies) {
if (!(React.useEffect instanceof Function))
return;
if (!(React.useEffect instanceof Function)) return;

React.useEffect(() => {
// check and correct 1st parameter
if (!(nodeFactory instanceof Function)) {
console.warn('useCode() first argument should be a function that returns an animation node.');
// check and correct 1st parameter
if (!(nodeFactory instanceof Function)) {
console.warn(
'useCode() first argument should be a function that returns an animation node.'
);

const node = nodeFactory;
nodeFactory = () => node;
}
const node = nodeFactory;
nodeFactory = () => node;
}

let node = nodeFactory();
if (node) {
// allow factory to return array
if (node instanceof Array)
node = block(node);
let node = nodeFactory();
if (node) {
// allow factory to return array
if (node instanceof Array) node = block(node);

const animatedAlways = always(node);
animatedAlways.__attach();
const animatedAlways = always(node);
animatedAlways.__attach();

// return undo function
return () => animatedAlways.__detach();
}
},
dependencies
);
// return undo function
return () => animatedAlways.__detach();
}
}, dependencies);
}
Loading