@@ -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' ) ;
@@ -56,6 +58,7 @@ describe('Unit testing for ButtonContainer', () => {
5658 render ( < ButtonsContainer /> ) ;
5759 expect ( screen . getAllByRole ( 'button' ) ) . toHaveLength ( 4 ) ;
5860 expect ( screen . getAllByRole ( 'button' ) [ 0 ] ) . toHaveTextContent ( 'Unlocked' ) ;
61+ console . log ( 'button:' , screen . getAllByRole ( 'button' ) [ 0 ] )
5962 expect ( screen . getAllByRole ( 'button' ) [ 1 ] ) . toHaveTextContent ( 'Download' ) ;
6063 expect ( screen . getAllByRole ( 'button' ) [ 2 ] ) . toHaveTextContent ( 'Upload' ) ;
6164 expect ( screen . getAllByRole ( 'button' ) [ 3 ] ) . toHaveTextContent ( 'Tutorial' ) ;
@@ -70,6 +73,24 @@ describe('Unit testing for ButtonContainer', () => {
7073 } ) ;
7174 } ) ;
7275
76+ describe ( 'When view is lock' , ( ) => {
77+ test ( 'Button should show as locked' , ( ) => {
78+ state . tabs [ '87' ] . mode . paused = false ;
79+ render ( < ButtonsContainer /> ) ;
80+ expect ( screen . getAllByRole ( 'button' ) [ 0 ] ) . toHaveTextContent ( 'Unlocked' ) ;
81+ } ) ;
82+ } ) ;
83+
84+ describe ( 'Clicking pause-button toggles locked/unlocked' , ( ) => {
85+ test ( 'When button is unlocked and it is clicked' , async ( ) => {
86+ render ( < ButtonsContainer /> ) ;
87+ const button = screen . getAllByRole ( 'button' ) [ 0 ] ;
88+ await userEvent . click ( button ) ;
89+ expect ( dispatch ) . toHaveBeenCalledWith ( toggleMode ( 'paused' ) ) ;
90+ } ) ;
91+ } ) ;
92+
93+
7394 describe ( 'Upload/Download' , ( ) => {
7495 test ( 'Clicking upload and download buttons' , async ( ) => {
7596 render ( < ButtonsContainer /> ) ;
0 commit comments