From 5fac3a07801dfe2ba07f1ab6e8aaabe1bfeab36e Mon Sep 17 00:00:00 2001 From: lukas Date: Sat, 1 May 2021 15:18:38 +0200 Subject: [PATCH] add some unit tests --- .../DynamicContentContainer.test.js | 12 ++++++++++++ src/pages/TVShowPage/TVPlayer.test.js | 10 ++++++++++ src/pages/TVShowPage/TVPlayer.tsx | 2 +- src/pages/TVShowPage/TVShowPage.test.js | 10 ++++++++++ src/pages/TVShowPage/TVShowPage.tsx | 2 +- 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/pages/TVShowPage/TVPlayer.test.js create mode 100644 src/pages/TVShowPage/TVShowPage.test.js diff --git a/src/elements/DynamicContentContainer/DynamicContentContainer.test.js b/src/elements/DynamicContentContainer/DynamicContentContainer.test.js index 2792ce3..53c916a 100644 --- a/src/elements/DynamicContentContainer/DynamicContentContainer.test.js +++ b/src/elements/DynamicContentContainer/DynamicContentContainer.test.js @@ -34,4 +34,16 @@ describe('', function () { wrapper.instance().clean(); expect(wrapper.find('a')).toHaveLength(0); }); + + it('test update', function () { + const wrapper = shallow( ()}/>); + + const func = jest.fn(); + wrapper.instance().clean = func; + + // perform component update + wrapper.setProps({data: [{}, {}]}); + + expect(func).toHaveBeenCalledTimes(1); + }); }); diff --git a/src/pages/TVShowPage/TVPlayer.test.js b/src/pages/TVShowPage/TVPlayer.test.js new file mode 100644 index 0000000..892e6cd --- /dev/null +++ b/src/pages/TVShowPage/TVPlayer.test.js @@ -0,0 +1,10 @@ +import {shallow} from 'enzyme'; +import {TVPlayer} from './TVPlayer'; +import React from 'react'; + +describe('', () => { + it('renders without crashing', function () { + const wrapper = shallow(); + wrapper.unmount(); + }); +}) diff --git a/src/pages/TVShowPage/TVPlayer.tsx b/src/pages/TVShowPage/TVPlayer.tsx index 40f0fa1..6885e32 100644 --- a/src/pages/TVShowPage/TVPlayer.tsx +++ b/src/pages/TVShowPage/TVPlayer.tsx @@ -24,7 +24,7 @@ interface EpisodeData { Path: string; } -class TVPlayer extends React.Component { +export class TVPlayer extends React.Component { state = { loaded: false }; diff --git a/src/pages/TVShowPage/TVShowPage.test.js b/src/pages/TVShowPage/TVShowPage.test.js new file mode 100644 index 0000000..c1e7af6 --- /dev/null +++ b/src/pages/TVShowPage/TVShowPage.test.js @@ -0,0 +1,10 @@ +import {shallow} from 'enzyme'; +import {TVShowPage} from './TVShowPage'; +import React from 'react'; + +describe('', () => { + it('renders without crashing', function () { + const wrapper = shallow(); + wrapper.unmount(); + }); +}) diff --git a/src/pages/TVShowPage/TVShowPage.tsx b/src/pages/TVShowPage/TVShowPage.tsx index 4e14191..eee8d71 100644 --- a/src/pages/TVShowPage/TVShowPage.tsx +++ b/src/pages/TVShowPage/TVShowPage.tsx @@ -14,7 +14,7 @@ interface State { interface Props {} -class TVShowPage extends React.Component { +export class TVShowPage extends React.Component { state = { loading: true };