Commit 383ec43a authored by Christoph Häfner's avatar Christoph Häfner

Implement NeverSeenIt Button in MovieChoose Component

parent 1b006f29
Pipeline #454 passed with stages
in 12 minutes and 8 seconds
import React from 'react'
import * as UnseenMovieListActions from '../../unseenMovieList/actions';
import MovieChooseForm from './MovieChooseForm';
import getUnratedAndSeenMovieFromCollection from '../lib/getUnratedAndSeenMovieFromCollection'
......@@ -8,6 +9,7 @@ export default class MovieChoose extends React.Component {
super(props)
this.dispatch = props.dispatch
this.start = this.start.bind(this);
this.neverSeenIt = this.neverSeenIt.bind(this);
}
start(event) {
......@@ -17,13 +19,19 @@ export default class MovieChoose extends React.Component {
})
}
neverSeenIt(event) {
this.dispatch(UnseenMovieListActions.addMovieToUnseenMovieList(this.movie.movieId));
}
render() {
const collectionId = this.props.collectionId
this.movieCollection = this.props.movieCollections[collectionId]
this.movie = getUnratedAndSeenMovieFromCollection(this.movieCollection,
this.props.rate.personalMovieList, this.props.rate.unseenMovieList)
return (
<MovieChooseForm onStart={this.start}
onNeverSeenIt={this.neverSeenIt}
movie={this.movie} />
)
}
......
......@@ -4,7 +4,6 @@ export default ({ onStart, onNeverSeenIt, movie }) => (
<div>
<Movie {...movie} />
<button type="button"
disabled="true"
onClick={onNeverSeenIt}
>
Never Seen It
......
......@@ -2,6 +2,7 @@ import { expect as chaiExpect } from 'chai'
import { mount } from 'enzyme'
import MovieChoose from '../../../../src/rate/process/components/MovieChoose'
import { ADD_MOVIE_TO_UNSEEN_MOVIE_LIST } from '../../../../src/rate/unseenMovieList/actions'
describe('MovieChoose', () => {
const minimumRequiredProps = {
......@@ -26,6 +27,23 @@ describe('MovieChoose', () => {
expect(props.onStart).toHaveBeenCalledTimes(1);
})
it('should call dispatch if neverSeenIt button is clicked', () => {
const props = Object.assign({
dispatch: jest.fn()
}, minimumRequiredProps);
const wrapper = mount(<MovieChoose {...props} />);
const neverSeenItButton = wrapper.find('button').at(0);
neverSeenItButton.simulate('click');
expect(props.dispatch).toHaveBeenCalledTimes(1);
expect(props.dispatch).toHaveBeenCalledWith({
type: ADD_MOVIE_TO_UNSEEN_MOVIE_LIST,
payload: {
movieId: '1'
}
});
})
it('should render unrated movie', () => {
const props = Object.assign(minimumRequiredProps, {
onStart: jest.fn(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment