@@ -5,6 +5,8 @@ import { TextEncoder } from 'util';
55global . TextEncoder = TextEncoder ;
66import ButtonsContainer from '../containers/ButtonsContainer' ;
77import { useStoreContext } from '../store' ;
8+ import userEvent from '@testing-library/user-event' ;
9+ import { toggleMode } from '../actions/actions' ;
810
911// const { Steps } = require('intro.js-react');
1012jest . mock ( '../store' ) ;
@@ -69,6 +71,24 @@ describe('Unit testing for ButtonContainer', () => {
6971 } ) ;
7072 } ) ;
7173
74+ describe ( 'When view is lock' , ( ) => {
75+ test ( 'Button should show as locked' , ( ) => {
76+ state . tabs [ '87' ] . mode . paused = false ;
77+ render ( < ButtonsContainer /> ) ;
78+ expect ( screen . getAllByRole ( 'button' ) [ 0 ] ) . toHaveTextContent ( 'Unlocked' ) ;
79+ } ) ;
80+ } ) ;
81+
82+ describe ( 'Clicking pause-button toggles locked/unlocked' , ( ) => {
83+ test ( 'When button is unlocked and it is clicked' , async ( ) => {
84+ render ( < ButtonsContainer /> ) ;
85+ const button = screen . getAllByRole ( 'button' ) [ 0 ] ;
86+ await userEvent . click ( button ) ;
87+ expect ( dispatch ) . toHaveBeenCalledWith ( toggleMode ( 'paused' ) ) ;
88+ } ) ;
89+ } ) ;
90+
91+
7292 describe ( 'Upload/Download' , ( ) => {
7393 test ( 'Clicking upload and download buttons' , async ( ) => {
7494 render ( < ButtonsContainer /> ) ;
0 commit comments