/**
 * Tone JS Mock
 *
 * NOTE: Tone's sub-module classes are rebuilt with injected mock functions so
 * Jest can spy on them. This isn't the best option, but I was unable to mock
 * Tone's classes using mockImplementation as it is difficult to access them
 * directly.
 */ const Master = { volume : { value : 0 } , mute : false , chain : jest . fn ( ) , dispose : jest . fn ( ) } ; const Transport = { bpm : { value : null } , start : jest . fn ( ) , stop : jest . fn ( ) } ; export const mockChannelConstructor = jest . fn ( ) ; export const mockChannelVolume = jest . fn ( ) ; export const mockChannelPan = jest . fn ( ) ; export const mockChannelDispose = jest . fn ( ) ; class Channel { constructor ( volume , pan ) { mockChannelConstructor ( volume , pan ) ; this . volume = { value : volume } ; this . pan = { value : pan } ; this . dispose = mockChannelDispose ; mockChannelVolume ( this . volume . value ) ; mockChannelPan ( this . pan . value ) ; } } export const mockPolySynthConstructor = jest . fn ( ) ; export const mockPolySynthTriggerAttack = jest . fn ( ) ; export const mockPolySynthTriggerRelease = jest . fn ( ) ; export const mockPolySynthDispose = jest . fn ( ) ; export const mockPolySynthChain = jest . fn ( ) ; export const mockPolySynthSet = jest . fn ( ) ; class PolySynth { constructor ( polyphony , voice , voiceArgs ) { mockPolySynthConstructor ( polyphony , voice , voiceArgs ) ; this . triggerAttack = mockPolySynthTriggerAttack ; this . triggerRelease = mockPolySynthTriggerRelease ; this . dispose = mockPolySynthDispose ; this . chain = mockPolySynthChain ; this . set = mockPolySynthSet ; this . disconnect = jest . fn ( ) ; } } const Synth = 'Synth' ; const AMSynth = 'AMSynth' ; const DuoSynth = 'DuoSynth' ; const FMSynth = 'FMSynth' ; const MonoSynth = 'MonoSynth' ; export const mockMembraneSynthConstructor = jest . fn ( ) ; class MembraneSynth { constructor ( options ) { mockMembraneSynthConstructor ( options ) ; this . triggerAttack = jest . fn ( ) ; this . triggerRelease = jest . fn ( ) ; this . dispose = jest . fn ( ) ; this . chain = jest . fn ( ) ; this . disconnect = jest . fn ( ) ; } } export const mockMetalSynthConstructor = jest . fn ( ) ; class MetalSynth { constructor ( options ) { mockMetalSynthConstructor ( options ) ; this . triggerAttack = jest . fn ( ) ; this . triggerRelease = jest . fn ( ) ; this . dispose = jest . fn ( ) ; this . chain = jest . fn ( ) ; this . disconnect = jest . fn ( ) ; } } export const mockNoiseSynthConstructor = jest . fn ( ) ; class NoiseSynth { constructor ( options ) { mockNoiseSynthConstructor ( options ) ; this . triggerAttack = jest . fn ( ) ; this . triggerRelease = jest . fn ( ) ; this . dispose = jest . fn ( ) ; this . chain = jest . fn ( ) ; this . disconnect = jest . fn ( ) ; } } export const mockPluckSynthConstructor = jest . fn ( ) ; class PluckSynth { constructor ( options ) { mockPluckSynthConstructor ( options ) ; this . triggerAttack = jest . fn ( ) ; this . triggerRelease = jest . fn ( ) ; this . dispose = jest . fn ( ) ; this . chain = jest . fn ( ) ; this . disconnect = jest . fn ( ) ; } } export const mockSamplerConstructor = jest . fn ( ) ; export const mockSamplerDispose = jest . fn ( ) ; export const mockSamplerAdd = jest . fn ( ) ; class Sampler { constructor ( samples ) { mockSamplerConstructor ( samples ) ; this . add = mockSamplerAdd ; this . dispose = mockSamplerDispose ; this . chain = jest . fn ( ) ; this . disconnect = jest . fn ( ) ; } } export const mockAutoFilterConstructor = jest . fn ( ) ; class AutoFilter { constructor ( ) { mockAutoFilterConstructor ( ) ; this . wet = { value : 1 } ; } } export const mockAutoPannerConstructor = jest . fn ( ) ; class AutoPanner { constructor ( ) { mockAutoPannerConstructor ( ) ; } } export const mockEQ3Constructor = jest . fn ( ) ; class EQ3 { constructor ( low , mid , high ) { mockEQ3Constructor ( low , mid , high ) ; this . low = { value : low } ; this . mid = { value : mid } ; this . high = { value : high } ; this . lowFrequency = { value : 400 } ; this . highFrequency = { value : 2500 } ; } } export const mockSequenceConstructor = jest . fn ( ) ; export const mockSequenceAdd = jest . fn ( ) ; export const mockSequenceRemove = jest . fn ( ) ; export const mockSequenceRemoveAll = jest . fn ( ) ; class Sequence { constructor ( callback , steps ) { mockSequenceConstructor ( steps ) ; this . start = jest . fn ( ) ; this . stop = jest . fn ( ) ; this . add = mockSequenceAdd ; this . remove = mockSequenceRemove ; this . removeAll = mockSequenceRemoveAll ; this . dispose = jest . fn ( ) ; } } const MockTone = { Master , Transport , Channel , PolySynth , Synth , AMSynth , DuoSynth , FMSynth , MembraneSynth , MetalSynth , MonoSynth , NoiseSynth , PluckSynth , Sampler , AutoFilter , AutoPanner , EQ3 , Sequence } ; export default MockTone ;