Skip to content

Commit

Permalink
updated test suite and improve project structure
Browse files Browse the repository at this point in the history
using constants for screen names now for avoiding mistakes.
  • Loading branch information
proshoumma committed Jan 22, 2018
1 parent 8ad67d4 commit d75afbf
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 17 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -10,12 +10,14 @@
"test": "jest"
},
"dependencies": {
"lodash": "^4.17.4",
"react": "16.2.0",
"react-native": "0.51.0",
"react-native-navigation": "^1.1.346"
},
"devDependencies": {
"@types/jest": "^22.0.1",
"@types/lodash": "^4.14.93",
"@types/react": "^16.0.34",
"@types/react-native": "0.51.0",
"@types/react-test-renderer": "^16.0.0",
Expand Down
9 changes: 6 additions & 3 deletions src/App.ts
@@ -1,13 +1,16 @@
import { Navigation } from 'react-native-navigation'

import { registerScreens } from './screens'
import { LANDING } from './screens/constants'

// register all the screens
registerScreens()

// start the app
Navigation.startSingleScreenApp({
screen: {
screen: 'Landing',
title: 'Landing'
screen: LANDING
}
});
})

export default Navigation
19 changes: 9 additions & 10 deletions src/__tests__/App.tsx
@@ -1,12 +1,11 @@
// import 'react-native';
// import * as React from 'react';
// import * as renderer from 'react-test-renderer';
// import {} from 'jest'
import {} from 'jest'
import * as _ from 'lodash'
import { Navigation } from 'react-native-navigation'

// import App from '../App';
import App from '../App'

// it('renders correctly', () => {
// const tree = renderer.create(
// <App />
// );
// });
describe('App', () => {
it('got a Navigation object', () => {
expect(_.isEqual(App, Navigation)).toBe(true)
})
})
14 changes: 14 additions & 0 deletions src/screens/Landing/__tests__/index.tsx
@@ -0,0 +1,14 @@
import 'react-native';
import * as React from 'react';
import * as renderer from 'react-test-renderer';
import {} from 'jest'

import Landing from '../';

describe('Landing Screen', () => {
it('renders correctly', () => {
const tree = renderer.create(
<Landing />
);
});
})
2 changes: 2 additions & 0 deletions src/screens/constants.ts
@@ -0,0 +1,2 @@
// using constants for screen names for avoiding mistakes
export const LANDING:string = 'Landing'
9 changes: 5 additions & 4 deletions src/screens/index.ts
@@ -1,7 +1,8 @@
import { Navigation } from 'react-native-navigation';
import { Navigation } from 'react-native-navigation'

import Landing from './Landing';
import Landing from './Landing'
import { LANDING } from './constants'

export function registerScreens() {
Navigation.registerComponent('Landing', () => Landing);
}
Navigation.registerComponent(LANDING, () => Landing)
}
4 changes: 4 additions & 0 deletions yarn.lock
Expand Up @@ -14,6 +14,10 @@
version "22.0.1"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-22.0.1.tgz#6370a6d60cce3845e4cd5d00bf65f654264685bc"

"@types/lodash@^4.14.93":
version "4.14.93"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.93.tgz#a6d2a1e1601a3c29196f38ef1990b68a9afa1e1c"

"@types/node@*":
version "9.3.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.3.0.tgz#3a129cda7c4e5df2409702626892cb4b96546dd5"
Expand Down

0 comments on commit d75afbf

Please sign in to comment.