From 1e26992f450664a113c295d883ec04d83500b2c8 Mon Sep 17 00:00:00 2001 From: Paul Kaplan <pkaplan@media.mit.edu> Date: Fri, 13 Oct 2017 12:42:48 -0400 Subject: [PATCH] Fix enzyme tests --- test/unit/containers/sound-editor.test.jsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/unit/containers/sound-editor.test.jsx b/test/unit/containers/sound-editor.test.jsx index 325488a25..63199ef01 100644 --- a/test/unit/containers/sound-editor.test.jsx +++ b/test/unit/containers/sound-editor.test.jsx @@ -63,7 +63,7 @@ describe('Sound Editor Container', () => { store={store} /> ); - const component = wrapper.find(SoundEditorComponent); + let component = wrapper.find(SoundEditorComponent); // Ensure rendering doesn't start playing any sounds expect(mockAudioBufferPlayer.instance.play.mock.calls).toEqual([]); expect(mockAudioBufferPlayer.instance.stop.mock.calls).toEqual([]); @@ -73,9 +73,13 @@ describe('Sound Editor Container', () => { // Mock the audio buffer player calling onUpdate mockAudioBufferPlayer.instance.onUpdate(0.5); + wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(component.props().playhead).toEqual(0.5); component.props().onStop(); + wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(mockAudioBufferPlayer.instance.stop).toHaveBeenCalled(); expect(component.props().playhead).toEqual(null); }); @@ -87,13 +91,17 @@ describe('Sound Editor Container', () => { store={store} /> ); - const component = wrapper.find(SoundEditorComponent); + let component = wrapper.find(SoundEditorComponent); component.props().onActivateTrim(); + wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(component.props().trimStart).not.toEqual(null); expect(component.props().trimEnd).not.toEqual(null); component.props().onActivateTrim(); + wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(vm.updateSoundBuffer).toHaveBeenCalled(); expect(component.props().trimStart).toEqual(null); expect(component.props().trimEnd).toEqual(null); @@ -223,7 +231,7 @@ describe('Sound Editor Container', () => { store={store} /> ); - const component = wrapper.find(SoundEditorComponent); + let component = wrapper.find(SoundEditorComponent); // Undo and redo should be disabled initially expect(component.prop('canUndo')).toEqual(false); expect(component.prop('canRedo')).toEqual(false); @@ -232,27 +240,34 @@ describe('Sound Editor Container', () => { component.props().onActivateTrim(); // Activate trimming component.props().onActivateTrim(); // Submit new samples by calling again wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(component.prop('canUndo')).toEqual(true); expect(component.prop('canRedo')).toEqual(false); // Undoing should make it possible to redo and not possible to undo again component.props().onUndo(); wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(component.prop('canUndo')).toEqual(false); expect(component.prop('canRedo')).toEqual(true); // Redoing should make it possible to undo and not possible to redo again component.props().onRedo(); wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(component.prop('canUndo')).toEqual(true); expect(component.prop('canRedo')).toEqual(false); // New submission should clear the redo stack component.props().onUndo(); // Undo to go back to a state where redo is enabled wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(component.prop('canRedo')).toEqual(true); component.props().onActivateTrim(); // Activate trimming component.props().onActivateTrim(); // Submit new samples by calling again + + wrapper.update(); + component = wrapper.find(SoundEditorComponent); expect(component.prop('canRedo')).toEqual(false); }); }); -- GitLab