fix unit tests

This commit is contained in:
lukas 2021-08-28 22:55:27 +02:00
parent f8dbadc45b
commit 7ebc5766e9
3 changed files with 17 additions and 4 deletions

View File

@ -25,7 +25,7 @@ describe('<NewActorPopupContent/>', () => {
const wrapper = shallow(<NewActorPopupContent onHide={() => {func();}}/>);
// manually set typed in actorname
wrapper.instance().value = 'testactorname';
wrapper.instance().nameValue = 'testactorname';
global.fetch = prepareFetchApi({});
@ -55,6 +55,6 @@ describe('<NewActorPopupContent/>', () => {
wrapper.find('input').simulate('change', {target: {value: 'testinput'}});
expect(wrapper.instance().value).toBe('testinput');
expect(wrapper.instance().nameValue).toBe('testinput');
});
});

View File

@ -109,7 +109,20 @@ describe('<Player/>', function () {
const func = jest.fn();
wrapper.setProps({history: {goBack: func}});
wrapper.setProps({history: {push: func}});
expect(func).toHaveBeenCalledTimes(0);
wrapper.find('.closebutton').simulate('click');
// there shouldn't be a backstack available
expect(func).toHaveBeenCalledTimes(1);
});
it('hide click with stack available', function () {
const wrapper = instance();
const func = jest.fn();
wrapper.setProps({history: {goBack: func, length: 5}});
expect(func).toHaveBeenCalledTimes(0);
wrapper.find('.closebutton').simulate('click');

View File

@ -316,7 +316,7 @@ export class Player extends React.Component<Props, mystate> {
closebtn(): void {
const hist = this.props.history;
if (hist.length > 1) {
this.props.history.goBack();
hist.goBack();
} else {
hist.push('/');
}