import React from 'react'; import { render } from '@testing-library/react'; import Tone from 'tone'; import { Song, Track, Instrument, Effect } from '..'; import { mockAutoFilterConstructor, mockAutoPannerConstructor, mockPolySynthChain, mockChannelConstructor, } from '../__mocks__/tone'; beforeEach(() => { jest.resetAllMocks(); }); describe('Effect', () => { // TODO: Fix theses tests after upgrading Tone JS to v14 xit('should add and remove effects from Instrument', () => { const { rerender } = render( , ); expect(mockAutoFilterConstructor).toBeCalled(); expect(mockPolySynthChain).toHaveBeenLastCalledWith( { id: 'effect-1', wet: { value: 1 } }, { dispose: mockChannelConstructor, mute: undefined, solo: undefined, pan: { value: 0 }, volume: { value: 0 }, }, Tone.Master, ); rerender( // // // // } > , ); expect(mockAutoPannerConstructor).toBeCalled(); expect(mockPolySynthChain).toHaveBeenLastCalledWith( { id: 'effect-2' }, { id: 'effect-1', wet: { value: 1 } }, { pan: { value: 0 }, volume: { value: 0 } }, Tone.Master, ); rerender( // // // } > , ); expect(mockPolySynthChain).toHaveBeenLastCalledWith( { id: 'effect-2' }, { pan: { value: 0 }, volume: { value: 0 } }, Tone.Master, ); rerender( , ); expect(mockPolySynthChain).toHaveBeenLastCalledWith( { pan: { value: 0 }, volume: { value: 0 }, }, Tone.Master, ); }); // TODO: Fix these tests after upgrading Tone JS to v14 xit('should update wet prop', () => { render( , ); expect(mockPolySynthChain).toHaveBeenLastCalledWith( { id: 'effect-1', wet: { value: 0.5 } }, { pan: { value: 0 }, volume: { value: 0 } }, Tone.Master, ); }); // TODO: Fix these tests after upgrading Tone JS to v14 xit('should add EQ3 effect and then update frequency', () => { const { rerender } = render( , ); expect(mockPolySynthChain).toHaveBeenLastCalledWith( { id: 'effect-1', low: { value: -6 }, mid: { value: 3 }, high: { value: 1 }, lowFrequency: { value: 400 }, highFrequency: { value: 2500 }, }, { pan: { value: 0 }, volume: { value: 0 } }, Tone.Master, ); rerender( , ); expect(mockPolySynthChain).toHaveBeenLastCalledWith( { id: 'effect-1', low: { value: -3 }, mid: { value: 1 }, high: { value: 0 }, lowFrequency: { value: 100 }, highFrequency: { value: 3000 }, }, { pan: { value: 0 }, volume: { value: 0 } }, Tone.Master, ); }); });