Skip to content

Commit

Permalink
Merge pull request #98 from SmartPhoneAppsProject/fix/LentScanScreen
Browse files Browse the repository at this point in the history
Fix/lent scan screen
  • Loading branch information
kkenya authored Jul 24, 2018
2 parents 53138d6 + 9f28ecd commit 9a17216
Show file tree
Hide file tree
Showing 34 changed files with 1,409 additions and 1,275 deletions.
8 changes: 4 additions & 4 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import { StackNavigator } from 'react-navigation';
import { createLogger } from 'redux-logger';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
import { getAllMockBooks } from './src/actions';
import { getAllBooks } from './src/actions';
import reducer from './src/reducers';

import HomeScreenContainer from './src/containers/HomeScreenContainer';
import SearchView from './src/components/HomeScreen/SearchView';
import DetailScreenContainer from './src/containers/DetailScreenContainer';
import LentScanScreenContainer from './src/containers/LentScanScreenContainer';
import EntryScreen from './src/components/screens/EntryScreen';
import ScanScreen from './src/components/screens/ScanScreen';
import EntryTagsScreen from './src/components/screens/EntryTagsScreen';
import LentScanScreen from './src/components/screens/LentScanScreen';
import { setTopLevelNavigator } from './src/utils/NavigationService';

const RootStack = StackNavigator(
Expand All @@ -40,7 +40,7 @@ const RootStack = StackNavigator(
screen: SearchView,
},
LentScan: {
screen: LentScanScreen,
screen: LentScanScreenContainer,
},
},
{
Expand Down Expand Up @@ -75,7 +75,7 @@ const store = createStore(
applyMiddleware(...middleware),
);

store.dispatch(getAllMockBooks());
store.dispatch(getAllBooks());

export default class App extends Component {
render() {
Expand Down
Binary file added assets/no_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/__tests__/actions/books.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import * as actions from '../../actions/index';
import * as actions from '../../actions';
import * as types from '../../constants/actionTypes';
import _books from '../../api/books.json';

Expand Down Expand Up @@ -31,7 +31,7 @@ describe('actions', () => {
];
const store = mockStore();

return store.dispatch(actions.getAllBooks())
return store.dispatch(actions.getAllMockBooks())
.then(() => {
expect(store.getActions()).toEqual(expected);
});
Expand Down
43 changes: 43 additions & 0 deletions src/__tests__/actions/scan.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as actions from '../../actions';
import * as types from '../../constants/actionTypes';

describe('actions', () => {
test('カメラのパーミッションが許可するアクションが生成されること', () => {
const expected = {
type: types.PERMISSIONS_GRANTED,
};
expect(actions.permissionsGranted()).toEqual(expected);
});

test('カメラのパーミッションが拒否されるアクションが生成されること', () => {
const expected = {
type: types.PERMISSIONS_DENIED,
};
expect(actions.permissionsDenied()).toEqual(expected);
});

test('カメラの読み取り中のアクションが生成されること', () => {
const expected = {
type: types.ISBN_READING,
};
expect(actions.isbnReading()).toEqual(expected);
});

test('カメラの読み取り完了のアクションが生成されること', () => {
const isbn = 1234567890123;
const expected = {
type: types.ISBN_OK,
payload: {
isbn,
},
};
expect(actions.isbnOk(isbn)).toEqual(expected);
});

test('カメラの読み取りエラーのアクションが生成されること', () => {
const expected = {
type: types.ISBN_INVALID,
};
expect(actions.isbnInvalid()).toEqual(expected);
});
});
24 changes: 24 additions & 0 deletions src/__tests__/components/LentScanScreen.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import renderer from 'react-test-renderer';

import LentScanScreen from '../../components/LentScanScreen';

describe('<LentScanScreen />', () => {
it('正しくレンダリングされること', () => {
const tree = renderer
.create(<LentScanScreen
permissions="granted"
status="reading"
isbn={null}
action="return"
permissionsGranted={jest.fn()}
permissionsDenied={jest.fn()}
isbnReading={jest.fn()}
isbnOk={jest.fn()}
isbnInvalid={jest.fn()}
requestChangeStatus={jest.fn()}
/>)
.toJSON();
expect(tree).toMatchSnapshot();
});
});
Loading

0 comments on commit 9a17216

Please sign in to comment.