diff --git a/.gitignore b/.gitignore index 6862e8a..41dec09 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ npm-debug.log* package-lock.json yarn-debug.log* yarn-error.log* + diff --git a/src/components/EventCard.js b/src/components/EventCard.js index e7ada6e..fcfa3fa 100644 --- a/src/components/EventCard.js +++ b/src/components/EventCard.js @@ -35,6 +35,36 @@ function EventCard(props: EventCardProps) { ); } +function renderIconAction(action: string) { + switch (action) { + case 'COMMENT_PR': + return ( + + ); + case 'COMMENT_ISSUE': + return ( + + ); + case 'PR': + return ( + + ); + case 'ISSUE': + return ( + + ); + case 'FORK': + return ; export function renderIconType(event: Event) { let type: string = event.type; if (event.type === 'IssuesEvent') { diff --git a/src/components/Repo.js b/src/components/Repo.js index d25c012..5862a0e 100644 --- a/src/components/Repo.js +++ b/src/components/Repo.js @@ -5,7 +5,7 @@ import {FontAwesome, Octicons, Entypo} from '@expo/vector-icons'; import {DARK_GREY} from '../global/constants/colors'; import languageColor from '../global/constants/languageColor'; -type Repo = { +export type Repo = { description: string; fork: boolean; forks: number; @@ -31,13 +31,11 @@ function repoComponent(props: Repo) { : null; langColor = langColor ? langColor : '#000000'; let langView = () => { - return language ? ( + return ( {language} - ) : ( - ); }; return ( diff --git a/src/components/__tests__/Repo.test.js b/src/components/__tests__/Repo.test.js new file mode 100644 index 0000000..57f9b04 --- /dev/null +++ b/src/components/__tests__/Repo.test.js @@ -0,0 +1,58 @@ +// @flow +import React from 'react'; +import renderer from 'react-test-renderer'; +import repoComponent from '../Repo'; + +describe('Button', () => { + let data = [ + { + description: 'a', + fork: true, + forks: 1, + link: () => true, + id: 232343, + language: 'JavaScript', + name: 'asdfew', + stargazersCount: 2, + }, + { + description: 'a', + fork: true, + forks: 1, + link: () => true, + id: 232343, + language: '---', + name: 'asdfew', + stargazersCount: 2, + }, + { + description: 'a', + fork: false, + forks: 1, + link: () => true, + id: 232343, + language: 'Apex', + name: 'asdfew', + stargazersCount: 2, + }, + ]; + + it('should render Button corectly', () => { + let repo = repoComponent(data[0]); + let component = renderer.create(repo); + let tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + it('should render with wrong language', () => { + let repo = repoComponent(data[1]); + let component = renderer.create(repo); + let tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); + it('should render with null langColor', () => { + let repo = repoComponent(data[2]); + let component = renderer.create(repo); + let tree = component.toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/src/components/__tests__/__snapshots__/EventCard.test.js.snap b/src/components/__tests__/__snapshots__/EventCard.test.js.snap index 6ab6681..bbf4f55 100644 --- a/src/components/__tests__/__snapshots__/EventCard.test.js.snap +++ b/src/components/__tests__/__snapshots__/EventCard.test.js.snap @@ -566,7 +566,7 @@ exports[`EventCard should render EventCard with comment correctly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > diff --git a/src/components/__tests__/__snapshots__/Repo.test.js.snap b/src/components/__tests__/__snapshots__/Repo.test.js.snap new file mode 100644 index 0000000..0612afb --- /dev/null +++ b/src/components/__tests__/__snapshots__/Repo.test.js.snap @@ -0,0 +1,484 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Button should render Button corectly 1`] = ` + + + + + asdfew + + + a + + + + + + 2 + + + + + + 1 + + + + + + JavaScript + + + + + + + + + +`; + +exports[`Button should render with null langColor 1`] = ` + + + + + asdfew + + + a + + + + + + 2 + + + + + + 1 + + + + + + Apex + + + + + + + + + +`; + +exports[`Button should render with wrong language 1`] = ` + + + + + asdfew + + + a + + + + + + 2 + + + + + + 1 + + + + + + --- + + + + + + + + + +`; diff --git a/src/features/auth/__tests__/loginReducer.test.js b/src/features/auth/__tests__/loginReducer.test.js index d183441..f92df82 100644 --- a/src/features/auth/__tests__/loginReducer.test.js +++ b/src/features/auth/__tests__/loginReducer.test.js @@ -22,4 +22,18 @@ describe('testing for login reducer', () => { token: '1231241482hhsabdba', }); }); + it('should return message and login false ', () => { + const action = { + type: 'ACTIONS/AUTH_GITHUB_FAILED', + payload: { + currentUser: {login: 'aji', email: 'ajilantang@gmail.com'}, + token: '1231241482hhsabdba', + }, + }; + const initialState = {isLogin: false}; + expect(loginReducer(initialState, action)).toEqual({ + isLogin: false, + message: undefined, + }); + }); }); diff --git a/src/features/events/__tests__/__snapshots__/EventsScreen.test.js.snap b/src/features/events/__tests__/__snapshots__/EventsScreen.test.js.snap index 7d8c684..603f880 100644 --- a/src/features/events/__tests__/__snapshots__/EventsScreen.test.js.snap +++ b/src/features/events/__tests__/__snapshots__/EventsScreen.test.js.snap @@ -1,7 +1,863 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`EventsScreen should render EventsScreen correctly 1`] = ` - - - -`; +exports[`container test should render LoginScreen corectly 1`] = ` + + + + + + + + + + + zzzcielo + + + commented on issue + + + Parallax Header Bug + + + at + + + astridtamara/bootcamp + + + + 1d + + + + + + + + + + [Test Long Comment] The bug is bugging me a lot. Good job fixing it in such short time.[Test Long Comment] The bug is bugging me a lot. Good job fixing it in such short time.[Test Long Comment] The bug is bugging me a lot. Good job fixing it in such short time.[Test Long Comment] The bug is bugging me a lot. Good job fixing it in such short time. + + + + + + + + + + + + astridtamara + + + opened issue + + + kodefox/kfstart + + + at + + + astridtamara/bootcamp + + + + 2d + + + + + + + + + + + + + + + + + + + zzzcielo + + + commented on pull request + + + Quick bug fix + + + at + + + astridtamara/bootcamp + + + + 4d + + + + + + + + + + The bug is bugging me a lot. Good job fixing it in such short time. + + + + + + + + + + + + astridtamara + + + opened pull request + + + kodefox/kfstart + + + at + + + astridtamara/bootcamp + + + + 6d + + + + + + + + + + + + + + + + + + + astridtamara + + + forked + + + kodefox/kfstart + + + at + + + astridtamara/bootcamp + + + + 6d + + + + + + + + + + + diff --git a/src/features/repository/screens/__tests__/__snapshots__/RepositoryDetailScreen.test.js.snap b/src/features/repository/screens/__tests__/__snapshots__/RepositoryDetailScreen.test.js.snap index 083796b..2f9ffe3 100644 --- a/src/features/repository/screens/__tests__/__snapshots__/RepositoryDetailScreen.test.js.snap +++ b/src/features/repository/screens/__tests__/__snapshots__/RepositoryDetailScreen.test.js.snap @@ -507,7 +507,7 @@ exports[`Repository screee should render Repository corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -642,7 +642,7 @@ exports[`Repository screee should render Repository corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -771,7 +771,7 @@ exports[`Repository screee should render Repository corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -1022,7 +1022,7 @@ exports[`Repository screee should render Repository corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -1261,7 +1261,7 @@ exports[`Repository screee should render Repository corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > diff --git a/src/features/repository/screens/fileList.js b/src/features/repository/screens/fileList.js index be7d2a7..660fada 100644 --- a/src/features/repository/screens/fileList.js +++ b/src/features/repository/screens/fileList.js @@ -124,7 +124,7 @@ export class fileList extends Component { path: onClickPath, name, }, - key: onClickPath, + key: sha, }); }} key={sha} diff --git a/src/features/search/__tests__/__snapshots__/SearchUserScreen.test.js.snap b/src/features/search/__tests__/__snapshots__/SearchUserScreen.test.js.snap index ca895d6..acd16c5 100644 --- a/src/features/search/__tests__/__snapshots__/SearchUserScreen.test.js.snap +++ b/src/features/search/__tests__/__snapshots__/SearchUserScreen.test.js.snap @@ -72,7 +72,7 @@ exports[`container test should render LoginScreen corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -197,7 +197,7 @@ exports[`container test should render LoginScreen corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -322,7 +322,7 @@ exports[`container test should render LoginScreen corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -447,7 +447,7 @@ exports[`container test should render LoginScreen corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -572,7 +572,7 @@ exports[`container test should render LoginScreen corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > diff --git a/src/features/user/__tests__/__snapshots__/UserScreen.test.js.snap b/src/features/user/__tests__/__snapshots__/UserScreen.test.js.snap index 203990b..2c74698 100644 --- a/src/features/user/__tests__/__snapshots__/UserScreen.test.js.snap +++ b/src/features/user/__tests__/__snapshots__/UserScreen.test.js.snap @@ -577,7 +577,7 @@ exports[`UserScreen should render UserScreen corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > @@ -707,7 +707,7 @@ exports[`UserScreen should render UserScreen corectly 1`] = ` "flexDirection": "row", "justifyContent": "center", }, - Array [], + Object {}, ] } > diff --git a/src/global/core-ui/Button.js b/src/global/core-ui/Button.js index cb784ef..c5d92b1 100644 --- a/src/global/core-ui/Button.js +++ b/src/global/core-ui/Button.js @@ -14,7 +14,7 @@ type Props = { onPress: (params?: mixed) => void; }; const Button = (props: Props) => { - let {styles = {}, onPress = () => null, title = '', ...otherProps} = props; + let {styles = {}, onPress, title, ...otherProps} = props; let { backgroundColor = DARK_GREY, borderRadius = 3, diff --git a/src/global/core-ui/RowWith3Column.js b/src/global/core-ui/RowWith3Column.js index 8700f1e..184675b 100644 --- a/src/global/core-ui/RowWith3Column.js +++ b/src/global/core-ui/RowWith3Column.js @@ -12,7 +12,7 @@ type Props = { function RowWith3Column(props: Props) { let {isTouchable, onPress} = props; - isTouchable = typeof isTouchable === undefined ? false : isTouchable; + isTouchable = isTouchable === undefined ? false : isTouchable; let rightContent = React.isValidElement(props.right) ? props.right : null; @@ -22,7 +22,7 @@ function RowWith3Column(props: Props) { ? props.content : null; - let containerStyle = props.style ? props.style : []; + let containerStyle = props.style !== undefined ? props.style : {}; return ( diff --git a/src/global/core-ui/__tests__/Button.test.js b/src/global/core-ui/__tests__/Button.test.js new file mode 100644 index 0000000..af1e3bb --- /dev/null +++ b/src/global/core-ui/__tests__/Button.test.js @@ -0,0 +1,16 @@ +// @flow +import React from 'react'; +import renderer from 'react-test-renderer'; +import Button from '../Button'; +import {View} from 'react-native'; + +describe('Button', () => { + let onPress = () => {}; + let title = 'Button'; + + it('should render Button corectly', () => { + let component = renderer.create(