@@ -5,6 +5,8 @@ import { TextEncoder } from 'util';
5
5
global . TextEncoder = TextEncoder ;
6
6
import ButtonsContainer from '../containers/ButtonsContainer' ;
7
7
import { useStoreContext } from '../store' ;
8
+ import userEvent from '@testing-library/user-event' ;
9
+ import { toggleMode } from '../actions/actions' ;
8
10
9
11
// const { Steps } = require('intro.js-react');
10
12
jest . mock ( '../store' ) ;
@@ -56,6 +58,7 @@ describe('Unit testing for ButtonContainer', () => {
56
58
render ( < ButtonsContainer /> ) ;
57
59
expect ( screen . getAllByRole ( 'button' ) ) . toHaveLength ( 4 ) ;
58
60
expect ( screen . getAllByRole ( 'button' ) [ 0 ] ) . toHaveTextContent ( 'Unlocked' ) ;
61
+ console . log ( 'button:' , screen . getAllByRole ( 'button' ) [ 0 ] )
59
62
expect ( screen . getAllByRole ( 'button' ) [ 1 ] ) . toHaveTextContent ( 'Download' ) ;
60
63
expect ( screen . getAllByRole ( 'button' ) [ 2 ] ) . toHaveTextContent ( 'Upload' ) ;
61
64
expect ( screen . getAllByRole ( 'button' ) [ 3 ] ) . toHaveTextContent ( 'Tutorial' ) ;
@@ -70,6 +73,24 @@ describe('Unit testing for ButtonContainer', () => {
70
73
} ) ;
71
74
} ) ;
72
75
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
+
73
94
describe ( 'Upload/Download' , ( ) => {
74
95
test ( 'Clicking upload and download buttons' , async ( ) => {
75
96
render ( < ButtonsContainer /> ) ;
0 commit comments