mirror of
https://github.com/Jellify-Music/App.git
synced 2026-04-21 00:58:32 -05:00
fix jest
This commit is contained in:
@@ -16,8 +16,6 @@ module.exports = {
|
||||
'./jest/setup/device-info.js', // JS to prevent Typescript implicit any warning
|
||||
'./jest/setup/google-cast.ts',
|
||||
'./jest/setup/reanimated.ts',
|
||||
'./jest/setup/rnfs.ts',
|
||||
'./jest/setup/rntp.ts',
|
||||
'./jest/setup/sentry.ts',
|
||||
'./jest/setup/nitro-fetch.ts',
|
||||
'./jest/setup/nitro-image.ts',
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
jest.mock('react-native-fs', () => {
|
||||
return {
|
||||
mkdir: jest.fn(),
|
||||
moveFile: jest.fn(),
|
||||
copyFile: jest.fn(),
|
||||
pathForBundle: jest.fn(),
|
||||
pathForGroup: jest.fn(),
|
||||
getFSInfo: jest.fn(),
|
||||
getAllExternalFilesDirs: jest.fn(),
|
||||
unlink: jest.fn(),
|
||||
exists: jest.fn(),
|
||||
stopDownload: jest.fn(),
|
||||
resumeDownload: jest.fn(),
|
||||
isResumable: jest.fn(),
|
||||
stopUpload: jest.fn(),
|
||||
completeHandlerIOS: jest.fn(),
|
||||
readDir: jest.fn(),
|
||||
readDirAssets: jest.fn(),
|
||||
existsAssets: jest.fn(),
|
||||
readdir: jest.fn(),
|
||||
setReadable: jest.fn(),
|
||||
stat: jest.fn(),
|
||||
readFile: jest.fn(),
|
||||
read: jest.fn(),
|
||||
readFileAssets: jest.fn(),
|
||||
hash: jest.fn(),
|
||||
copyFileAssets: jest.fn(),
|
||||
copyFileAssetsIOS: jest.fn(),
|
||||
copyAssetsVideoIOS: jest.fn(),
|
||||
writeFile: jest.fn(),
|
||||
appendFile: jest.fn(),
|
||||
write: jest.fn(),
|
||||
downloadFile: jest.fn(),
|
||||
uploadFiles: jest.fn(),
|
||||
touch: jest.fn(),
|
||||
MainBundlePath: jest.fn(),
|
||||
CachesDirectoryPath: jest.fn(),
|
||||
DocumentDirectoryPath: jest.fn(),
|
||||
ExternalDirectoryPath: jest.fn(),
|
||||
ExternalStorageDirectoryPath: jest.fn(),
|
||||
TemporaryDirectoryPath: jest.fn(),
|
||||
LibraryDirectoryPath: jest.fn(),
|
||||
PicturesDirectoryPath: jest.fn(),
|
||||
}
|
||||
})
|
||||
@@ -1,136 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
export let eventHandler: any
|
||||
|
||||
// https://github.com/doublesymmetry/react-native-track-player/issues/501
|
||||
jest.mock('react-native-track-player', () => {
|
||||
const listeners = new Map()
|
||||
|
||||
return {
|
||||
addEventListener: () => ({
|
||||
remove: jest.fn(),
|
||||
}),
|
||||
registerEventHandler: jest.fn(),
|
||||
registerPlaybackService: jest.fn(),
|
||||
setupPlayer: jest.fn().mockResolvedValue(undefined),
|
||||
destroy: jest.fn(),
|
||||
updateOptions: jest.fn(),
|
||||
reset: jest.fn(),
|
||||
add: jest.fn(),
|
||||
remove: jest.fn(),
|
||||
skip: jest.fn(),
|
||||
State: {
|
||||
None: 'none',
|
||||
Ready: 'ready',
|
||||
Playing: 'playing',
|
||||
Paused: 'paused',
|
||||
Stopped: 'stopped',
|
||||
Buffering: 'buffering',
|
||||
Loading: 'loading',
|
||||
Error: 'error',
|
||||
Ended: 'ended',
|
||||
},
|
||||
skipToNext: jest.fn(),
|
||||
skipToPrevious: jest.fn(),
|
||||
removeUpcomingTracks: jest.fn(),
|
||||
setQueue: jest.fn(),
|
||||
move: jest.fn(),
|
||||
seekBy: jest.fn(),
|
||||
setRepeatMode: jest.fn(),
|
||||
// playback commands
|
||||
play: jest.fn(),
|
||||
pause: jest.fn(),
|
||||
stop: jest.fn(),
|
||||
seekTo: jest.fn(),
|
||||
setVolume: jest.fn(),
|
||||
setRate: jest.fn(),
|
||||
// player getters
|
||||
getQueue: jest.fn(),
|
||||
getTrack: jest.fn(),
|
||||
getActiveTrackIndex: jest.fn().mockResolvedValue(0),
|
||||
getActiveTrack: jest.fn().mockResolvedValue({ id: '1', index: 0, item: { Id: '1' } }),
|
||||
getCurrentTrack: jest.fn(),
|
||||
getVolume: jest.fn(),
|
||||
getDuration: jest.fn(),
|
||||
getProgress: jest.fn().mockResolvedValue({ position: 0 }),
|
||||
getPlaybackState: jest.fn().mockResolvedValue({ state: 'playing' }),
|
||||
getBufferedPosition: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
getRate: jest.fn(),
|
||||
useProgress: () => ({
|
||||
position: 0,
|
||||
buffered: 150,
|
||||
duration: 200,
|
||||
}),
|
||||
usePlaybackState: () => 'playing',
|
||||
|
||||
// eslint-disable @typescript-eslint/no-explicit-any
|
||||
useTrackPlayerEvents: (events: Event[], handler: (variables: any) => void) => {
|
||||
eventHandler = handler
|
||||
},
|
||||
AppKilledPlaybackBehavior: {
|
||||
StopPlaybackAndRemoveNotification: 'stopPlaybackAndRemoveNotification',
|
||||
},
|
||||
Capability: {
|
||||
Play: 1,
|
||||
PlayFromId: 2,
|
||||
PlayFromSearch: 4,
|
||||
Pause: 8,
|
||||
Stop: 16,
|
||||
SeekTo: 32,
|
||||
Skip: 64,
|
||||
SkipToNext: 128,
|
||||
SkipToPrevious: 256,
|
||||
},
|
||||
IOSCategoryOptions: {
|
||||
MixWithOthers: 'mixWithOthers',
|
||||
DuckOthers: 'duckOthers',
|
||||
InterruptSpokenAudioAndMixWithOthers: 'interruptSpokenAudioAndMixWithOthers',
|
||||
AllowBluetooth: 'allowBluetooth',
|
||||
AllowBluetoothA2DP: 'allowBluetoothA2DP',
|
||||
AllowAirPlay: 'allowAirPlay',
|
||||
DefaultToSpeaker: 'defaultToSpeaker',
|
||||
},
|
||||
IOSCategoryMode: {
|
||||
Default: 'default',
|
||||
GameChat: 'gameChat',
|
||||
Measurement: 'measurement',
|
||||
MoviePlayback: 'moviePlayback',
|
||||
SpokenAudio: 'spokenAudio',
|
||||
VideoChat: 'videoChat',
|
||||
VideoRecording: 'videoRecording',
|
||||
VoiceChat: 'voiceChat',
|
||||
VoicePrompt: 'voicePrompt',
|
||||
},
|
||||
IOSCategory: {
|
||||
Playback: 'playback',
|
||||
PlaybackAndRecord: 'playbackAndRecord',
|
||||
MultiRoute: 'multiRoute',
|
||||
Ambient: 'ambient',
|
||||
SoloAmbient: 'soloAmbient',
|
||||
Record: 'record',
|
||||
PlayAndRecord: 'playAndRecord',
|
||||
},
|
||||
Event: {
|
||||
PlaybackActiveTrackChanged: 'playbackActiveTrackChanged',
|
||||
},
|
||||
RepeatMode: {
|
||||
Off: 0,
|
||||
Track: 1,
|
||||
Queue: 2,
|
||||
},
|
||||
TrackType: {
|
||||
Default: 'default',
|
||||
HLS: 'hls',
|
||||
SmoothStreaming: 'smoothStreaming',
|
||||
Dash: 'dash',
|
||||
},
|
||||
AndroidAudioContentType: {
|
||||
Music: 'music',
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
// Mock the gapless helper to avoid dynamic import issues in tests
|
||||
jest.mock('../../src/player/helpers/gapless', () => ({
|
||||
ensureUpcomingTracksInQueue: jest.fn().mockResolvedValue(undefined),
|
||||
}))
|
||||
Reference in New Issue
Block a user