@@ -63,7 +63,7 @@ describe('Sound Editor Container', () => {
63
63
store = { store }
64
64
/>
65
65
) ;
66
- const component = wrapper . find ( SoundEditorComponent ) ;
66
+ let component = wrapper . find ( SoundEditorComponent ) ;
67
67
// Ensure rendering doesn't start playing any sounds
68
68
expect ( mockAudioBufferPlayer . instance . play . mock . calls ) . toEqual ( [ ] ) ;
69
69
expect ( mockAudioBufferPlayer . instance . stop . mock . calls ) . toEqual ( [ ] ) ;
@@ -73,9 +73,13 @@ describe('Sound Editor Container', () => {
73
73
74
74
// Mock the audio buffer player calling onUpdate
75
75
mockAudioBufferPlayer . instance . onUpdate ( 0.5 ) ;
76
+ wrapper . update ( ) ;
77
+ component = wrapper . find ( SoundEditorComponent ) ;
76
78
expect ( component . props ( ) . playhead ) . toEqual ( 0.5 ) ;
77
79
78
80
component . props ( ) . onStop ( ) ;
81
+ wrapper . update ( ) ;
82
+ component = wrapper . find ( SoundEditorComponent ) ;
79
83
expect ( mockAudioBufferPlayer . instance . stop ) . toHaveBeenCalled ( ) ;
80
84
expect ( component . props ( ) . playhead ) . toEqual ( null ) ;
81
85
} ) ;
@@ -87,13 +91,17 @@ describe('Sound Editor Container', () => {
87
91
store = { store }
88
92
/>
89
93
) ;
90
- const component = wrapper . find ( SoundEditorComponent ) ;
94
+ let component = wrapper . find ( SoundEditorComponent ) ;
91
95
92
96
component . props ( ) . onActivateTrim ( ) ;
97
+ wrapper . update ( ) ;
98
+ component = wrapper . find ( SoundEditorComponent ) ;
93
99
expect ( component . props ( ) . trimStart ) . not . toEqual ( null ) ;
94
100
expect ( component . props ( ) . trimEnd ) . not . toEqual ( null ) ;
95
101
96
102
component . props ( ) . onActivateTrim ( ) ;
103
+ wrapper . update ( ) ;
104
+ component = wrapper . find ( SoundEditorComponent ) ;
97
105
expect ( vm . updateSoundBuffer ) . toHaveBeenCalled ( ) ;
98
106
expect ( component . props ( ) . trimStart ) . toEqual ( null ) ;
99
107
expect ( component . props ( ) . trimEnd ) . toEqual ( null ) ;
@@ -223,7 +231,7 @@ describe('Sound Editor Container', () => {
223
231
store = { store }
224
232
/>
225
233
) ;
226
- const component = wrapper . find ( SoundEditorComponent ) ;
234
+ let component = wrapper . find ( SoundEditorComponent ) ;
227
235
// Undo and redo should be disabled initially
228
236
expect ( component . prop ( 'canUndo' ) ) . toEqual ( false ) ;
229
237
expect ( component . prop ( 'canRedo' ) ) . toEqual ( false ) ;
@@ -232,27 +240,34 @@ describe('Sound Editor Container', () => {
232
240
component . props ( ) . onActivateTrim ( ) ; // Activate trimming
233
241
component . props ( ) . onActivateTrim ( ) ; // Submit new samples by calling again
234
242
wrapper . update ( ) ;
243
+ component = wrapper . find ( SoundEditorComponent ) ;
235
244
expect ( component . prop ( 'canUndo' ) ) . toEqual ( true ) ;
236
245
expect ( component . prop ( 'canRedo' ) ) . toEqual ( false ) ;
237
246
238
247
// Undoing should make it possible to redo and not possible to undo again
239
248
component . props ( ) . onUndo ( ) ;
240
249
wrapper . update ( ) ;
250
+ component = wrapper . find ( SoundEditorComponent ) ;
241
251
expect ( component . prop ( 'canUndo' ) ) . toEqual ( false ) ;
242
252
expect ( component . prop ( 'canRedo' ) ) . toEqual ( true ) ;
243
253
244
254
// Redoing should make it possible to undo and not possible to redo again
245
255
component . props ( ) . onRedo ( ) ;
246
256
wrapper . update ( ) ;
257
+ component = wrapper . find ( SoundEditorComponent ) ;
247
258
expect ( component . prop ( 'canUndo' ) ) . toEqual ( true ) ;
248
259
expect ( component . prop ( 'canRedo' ) ) . toEqual ( false ) ;
249
260
250
261
// New submission should clear the redo stack
251
262
component . props ( ) . onUndo ( ) ; // Undo to go back to a state where redo is enabled
252
263
wrapper . update ( ) ;
264
+ component = wrapper . find ( SoundEditorComponent ) ;
253
265
expect ( component . prop ( 'canRedo' ) ) . toEqual ( true ) ;
254
266
component . props ( ) . onActivateTrim ( ) ; // Activate trimming
255
267
component . props ( ) . onActivateTrim ( ) ; // Submit new samples by calling again
268
+
269
+ wrapper . update ( ) ;
270
+ component = wrapper . find ( SoundEditorComponent ) ;
256
271
expect ( component . prop ( 'canRedo' ) ) . toEqual ( false ) ;
257
272
} ) ;
258
273
} ) ;
0 commit comments