Commit f1dfb175 authored by Christoph Häfner's avatar Christoph Häfner

Add first tests for createMovieCollectionByFile

parent d2c5b62d
Pipeline #445 passed with stages
in 23 minutes and 53 seconds
import { expect as chaiExpect } from 'chai'
import * as Actions from '../../src/movieCollections/actions'
describe('movieCollections actions', () => {
describe('createMovieCollectionByFile', () => {
const defaultMovieCollection = {
name: 'Hugo Blurays',
file: "<xml></xml>"
};
const NOP = () => {};
it('should dispatch add movie collection by file start', () => {
const workerMock = () => {
return {
postMessage: NOP
}
}
const mockDispatch = jest.fn();
Actions.createMovieCollectionByFile(defaultMovieCollection, workerMock)(mockDispatch);
expect(mockDispatch).toHaveBeenCalledWith({
type: Actions.ADD_MOVIECOLLECTION_BY_FILE_START,
id: 673655561,
movieCollection: defaultMovieCollection
});
})
it('should instantiate worker with file path', () => {
const workerMock = (filePath) => {
chaiExpect(filePath).to.be.a('string');
chaiExpect(filePath).to.have.length.above(2);
return {
postMessage: NOP
}
}
Actions.createMovieCollectionByFile(defaultMovieCollection, workerMock)(NOP);
})
it('should post file content as message', () => {
const mockPostMessage = jest.fn();
const workerMock = (filePath) => {
return {
postMessage: mockPostMessage
}
}
Actions.createMovieCollectionByFile(defaultMovieCollection, workerMock)(NOP);
expect(mockPostMessage).toHaveBeenCalledWith(defaultMovieCollection.file);
})
});
})
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