describe('cleanWebChartData', () => { it('should return the expected array of data formatted for the toneWeb chart', () => { const expected = [ {"axis": "Analytical", "value": 0.883842}, {"axis": "Tentative", "value": 0.60858}, {"axis": "Positive", "value": 0.519797} ] const result = cleanWebChartData(mockCleaned.documentTone) expect(result).toEqual(expected) }) })
describe('DocumentToneDisplay', () => { let renderedComponent beforeEach(() => { renderedComponent = shallow(<DocumentToneDisplay documentTone={ mockCleaned.documentTone } />) }) it('should match snapshot', () => { expect(renderedComponent).toMatchSnapshot() }) it('should match snapshot when passed different results', () => { renderedComponent = shallow(<DocumentToneDisplay documentTone={ mockCleaned2.documentTone } />) expect(renderedComponent).toMatchSnapshot() }) })
describe('documentToneReducer', () => { it('should return the default state', () => { expect(documentToneReducer(undefined, {})).toEqual([]) }) it('ADD_DOCUMENT_TONE should return the array of tone objects', () => { const action = actions.addDocumentTone(mockCleaned.documentTone) const expected = mockCleaned.documentTone expect(documentToneReducer(undefined, action)).toEqual(expected) }) it('CLEAR_DOCUMENT_TONE should return the empty document tone array', () => { const action = actions.clearDocumentTone() const state = mockCleaned.documentTone const expected = [] expect(documentToneReducer(state, action)).toEqual(expected) }) })
describe('ToneWeb', () => { let renderedComponent let mockChartData beforeEach(() => { mockChartData = [cleanWebChartData(mockCleaned.documentTone)] renderedComponent = shallow(<ToneWeb chartData={ mockChartData } />) }) it('should match snapshot', () => { expect(renderedComponent).toMatchSnapshot() }) it('should match snapshot when passed different results', () => { mockChartData = [cleanWebChartData(mockCleaned2.documentTone)] renderedComponent = shallow(<ToneWeb chartData={ mockChartData } />) expect(renderedComponent).toMatchSnapshot() }) })
renderedComponent.instance().handleSubmit(mockSubmitEvent) expect(await mockAddDocumentTone).toHaveBeenCalledWith(mockCleaned.documentTone) }) expect(mockAddDocumentTone).toHaveBeenCalledWith(mockCleaned.documentTone) })
const expected = { type: 'ADD_DOCUMENT_TONE', documentTone: mockCleaned.documentTone expect(actions.addDocumentTone(mockCleaned.documentTone)).toEqual(expected) })
mockAddSentencesTone = jest.fn() mockHistory = { push: jest.fn() } mockDocumentTone = mockCleaned.documentTone mockSentences = mockCleaned.sentences renderedComponent = shallow( expect(await mockAddDocumentTone).toHaveBeenCalledWith(mockCleaned.documentTone) }) expect(mockAddDocumentTone).toHaveBeenCalledWith(mockCleaned.documentTone) })
describe('cleanDocumentTone', () => { it('should return an array of expected cleaned document tone objects', () => { const result = cleanDocumentTone(mockUncleaned) const expected = mockCleaned.documentTone expect(result).toEqual(expected) }) })