Permalink
Browse files

Add Jest tests and Codecov reports (#673)

* chore(test): add jest

* chore(coverage): add codecov to circleci

* chore(vscode): remove vscode from git

* chore(test): snapshot all component
  • Loading branch information...
xcarpentier authored and cooperka committed Dec 20, 2017
1 parent 5e94773 commit e0546481b39aa15b48aadd83de7cf84891ace9de
Showing with 5,094 additions and 104 deletions.
  1. +3 βˆ’0 .babelrc
  2. +2 βˆ’0 .npmignore
  3. +0 βˆ’15 .vscode/settings.json
  4. +1 βˆ’5 .watchmanconfig
  5. +2 βˆ’3 circle.yml
  6. +17 βˆ’3 package.json
  7. +11 βˆ’0 src/__tests__/Actions.test.js
  8. +11 βˆ’0 src/__tests__/Avatar.test.js
  9. +13 βˆ’0 src/__tests__/Bubble.test.js
  10. +5 βˆ’0 src/__tests__/Color.test.js
  11. +11 βˆ’0 src/__tests__/Composer.test.js
  12. +5 βˆ’0 src/__tests__/Constant.test.js
  13. +12 βˆ’0 src/__tests__/Day.test.js
  14. +11 βˆ’0 src/__tests__/GiftedAvatar.test.js
  15. +33 βˆ’0 src/__tests__/GiftedChat.test.js
  16. +11 βˆ’0 src/__tests__/InputToolbar.test.js
  17. +11 βˆ’0 src/__tests__/LoadEarlier.test.js
  18. +13 βˆ’0 src/__tests__/Message.test.js
  19. +11 βˆ’0 src/__tests__/MessageContainer.test.js
  20. +11 βˆ’0 src/__tests__/MessageImage.test.js
  21. +11 βˆ’0 src/__tests__/MessageText.test.js
  22. +11 βˆ’0 src/__tests__/Send.test.js
  23. +11 βˆ’0 src/__tests__/SystemMessage.test.js
  24. +12 βˆ’0 src/__tests__/Time.test.js
  25. +67 βˆ’0 src/__tests__/__snapshots__/Actions.test.js.snap
  26. +17 βˆ’0 src/__tests__/__snapshots__/Avatar.test.js.snap
  27. +62 βˆ’0 src/__tests__/__snapshots__/Bubble.test.js.snap
  28. +20 βˆ’0 src/__tests__/__snapshots__/Color.test.js.snap
  29. +34 βˆ’0 src/__tests__/__snapshots__/Composer.test.js.snap
  30. +11 βˆ’0 src/__tests__/__snapshots__/Constant.test.js.snap
  31. +40 βˆ’0 src/__tests__/__snapshots__/Day.test.js.snap
  32. +22 βˆ’0 src/__tests__/__snapshots__/GiftedAvatar.test.js.snap
  33. +12 βˆ’0 src/__tests__/__snapshots__/GiftedChat.test.js.snap
  34. +128 βˆ’0 src/__tests__/__snapshots__/InputToolbar.test.js.snap
  35. +67 βˆ’0 src/__tests__/__snapshots__/LoadEarlier.test.js.snap
  36. +83 βˆ’0 src/__tests__/__snapshots__/Message.test.js.snap
  37. +29 βˆ’0 src/__tests__/__snapshots__/MessageContainer.test.js.snap
  38. +199 βˆ’0 src/__tests__/__snapshots__/MessageImage.test.js.snap
  39. +62 βˆ’0 src/__tests__/__snapshots__/MessageText.test.js.snap
  40. +3 βˆ’0 src/__tests__/__snapshots__/Send.test.js.snap
  41. +44 βˆ’0 src/__tests__/__snapshots__/SystemMessage.test.js.snap
  42. +35 βˆ’0 src/__tests__/__snapshots__/Time.test.js.snap
  43. +32 βˆ’0 tests/context.js
  44. +3 βˆ’0 tests/setup.js
  45. +3,885 βˆ’78 yarn.lock
View
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
View
@@ -1,3 +1,5 @@
example/
TODO.md
screenshots/
.babelrc
tests/
View

This file was deleted.

Oops, something went wrong.
View
@@ -1,7 +1,3 @@
{
"ignore_dirs": [
".git",
"node_modules",
"example"
]
"ignore_dirs": [".git", "node_modules", "example"]
}
View
@@ -17,9 +17,8 @@ dependencies:
test:
override:
- yarn run lint
# TODO: - yarn run flow
# TODO: - yarn run test -- --coverage
# TODO: - codecov
- yarn run test:coverage
- codecov
# TODO: deployment:
# release:
View
@@ -25,17 +25,31 @@
"homepage": "https://github.com/FaridSafi/react-native-gifted-chat#readme",
"scripts": {
"lint": "eslint . --ext .js,.jsx",
"precommit": "yarn lint"
"precommit": "yarn lint",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage"
},
"jest": {
"preset": "react-native",
"setupFiles": ["./tests/setup.js"]
},
"devDependencies": {
"babel": "6.23.0",
"babel-jest": "22.0.3",
"babel-preset-react-native": "4.0.0",
"eslint": "^4.9.0",
"eslint-config-airbnb": "16.1.0",
"eslint-config-cooperka": "0.2.9",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-react-native": "3.2.0",
"husky": "0.14.3"
"husky": "0.14.3",
"jest": "22.0.3",
"react": "16.2.0",
"react-native": "0.51.0",
"react-test-renderer": "16.2.0"
},
"dependencies": {
"@expo/react-native-action-sheet": "^1.0.1",
@@ -49,4 +63,4 @@
"shallowequal": "1.0.2",
"uuid": "3.1.0"
}
}
}
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { Actions } from '../GiftedChat';
it('should render <Actions /> and compare with snapshot', () => {
const tree = renderer.create(<Actions />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { Avatar } from '../GiftedChat';
it('should render <Avatar /> and compare with snapshot', () => {
const tree = renderer.create(<Avatar renderAvatar={() => 'renderAvatar'} />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,13 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { Bubble } from '../GiftedChat';
it('should render <Bubble /> and compare with snapshot', () => {
const tree = renderer
.create(<Bubble user={{ _id: 1 }} currentMessage={{ user: { _id: 1 } }} />)
.toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,5 @@
import Color from '../Color';
it('should compare Color with snapshot', () => {
expect(Color).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { Composer } from '../GiftedChat';
it('should render <Composer /> and compare with snapshot', () => {
const tree = renderer.create(<Composer />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,5 @@
import * as Constant from '../Constant';
it('should compare Constant with snapshot', () => {
expect(Constant).toMatchSnapshot();
});
View
@@ -0,0 +1,12 @@
import 'react-native';
import React from 'react';
import createComponentWithContext from '../../tests/context';
import { Day } from '../GiftedChat';
it('should render <Day /> and compare with snapshot', () => {
const component = createComponentWithContext(<Day />);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { GiftedAvatar } from '../GiftedChat';
it('should render <GiftedAvatar /> and compare with snapshot', () => {
const tree = renderer.create(<GiftedAvatar />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,33 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { GiftedChat } from '../GiftedChat';
const messages = [
{
_id: 1,
text: 'Hello developer',
createdAt: new Date(),
user: {
_id: 2,
name: 'React Native',
},
},
];
it('should render <GiftedChat/> and compare with snapshot', () => {
const tree = renderer
.create(
<GiftedChat
messages={messages}
onSend={() => {}}
user={{
_id: 1,
}}
/>,
)
.toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { InputToolbar } from '../GiftedChat';
it('should render <InputToolbar /> and compare with snapshot', () => {
const tree = renderer.create(<InputToolbar />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { LoadEarlier } from '../GiftedChat';
it('should render <LoadEarlier /> and compare with snapshot', () => {
const tree = renderer.create(<LoadEarlier />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,13 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { Message } from '../GiftedChat';
it('should render <Message /> and compare with snapshot', () => {
const tree = renderer
.create(<Message user={{ _id: 1 }} currentMessage={{ user: { _id: 1 } }} />)
.toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { MessageContainer } from '../GiftedChat';
it('should render <MessageContainer /> and compare with snapshot', () => {
const tree = renderer.create(<MessageContainer />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { MessageImage } from '../GiftedChat';
it('should render <MessageImage /> and compare with snapshot', () => {
const tree = renderer.create(<MessageImage />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { MessageText } from '../GiftedChat';
it('should render <MessageText /> and compare with snapshot', () => {
const tree = renderer.create(<MessageText />).toJSON();
expect(tree).toMatchSnapshot();
});
View
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { Send } from '../GiftedChat';
it('should render <Send /> and compare with snapshot', () => {
const tree = renderer.create(<Send />).toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,11 @@
import 'react-native';
import React from 'react';
import renderer from 'react-test-renderer';
import { SystemMessage } from '../GiftedChat';
it('should render <SystemMessage /> and compare with snapshot', () => {
const tree = renderer.create(<SystemMessage />).toJSON();
expect(tree).toMatchSnapshot();
});
View
@@ -0,0 +1,12 @@
import 'react-native';
import React from 'react';
import createComponentWithContext from '../../tests/context';
import { Time } from '../GiftedChat';
it('should render <Time /> and compare with snapshot', () => {
const component = createComponentWithContext(<Time />);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
@@ -0,0 +1,67 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`should render <Actions /> and compare with snapshot 1`] = `
<View
accessibilityComponentType={undefined}
accessibilityLabel={undefined}
accessibilityTraits={undefined}
accessible={true}
collapsable={undefined}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={
Object {
"height": 26,
"marginBottom": 10,
"marginLeft": 10,
"opacity": 1,
"width": 26,
}
}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
Array [
Object {
"borderColor": "#b2b2b2",
"borderRadius": 13,
"borderWidth": 2,
"flex": 1,
},
Object {},
]
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Array [
Object {
"backgroundColor": "transparent",
"color": "#b2b2b2",
"fontSize": 16,
"fontWeight": "bold",
"textAlign": "center",
},
Object {},
]
}
>
+
</Text>
</View>
</View>
`;
Oops, something went wrong.

0 comments on commit e054648

Please sign in to comment.