Skip to content

Commit 6f967aa

Browse files
committed
fix: remove notify listeners
1 parent bd0db89 commit 6f967aa

File tree

1 file changed

+0
-26
lines changed

1 file changed

+0
-26
lines changed

__mocks__/react-native-track-player.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,25 @@ let duration = 0; // seconds
3535
let initialized = false;
3636
let queue: any[] = [];
3737

38-
// listeners for the hook-based mocks
39-
const progressListeners = new Set<
40-
(progress: { position: number; duration: number }) => void
41-
>();
42-
43-
const playbackStateListeners = new Set<(state: State) => void>();
44-
45-
function notifyProgress() {
46-
const progress = { position, duration };
47-
progressListeners.forEach(fn => fn(progress));
48-
}
49-
50-
function notifyPlaybackState() {
51-
playbackStateListeners.forEach(fn => fn(playbackState));
52-
}
53-
5438
export const testApi = {
5539
resetAll: () => {
5640
playbackState = State.Stopped;
5741
position = 0;
5842
duration = 0;
5943
initialized = false;
6044
queue = [];
61-
// notify subscribers of reset
62-
notifyProgress();
63-
notifyPlaybackState();
6445
},
6546
setPlaybackState: (state: State) => {
6647
playbackState = state;
67-
notifyPlaybackState();
6848
},
6949
setPosition: (seconds: number) => {
7050
position = seconds;
71-
notifyProgress();
7251
},
7352
setDuration: (seconds: number) => {
7453
duration = seconds;
75-
notifyProgress();
7654
},
7755
advance: (ms: number) => {
7856
position = Math.min(duration, position + ms / 1000);
79-
notifyProgress();
8057
},
8158
};
8259

@@ -89,7 +66,6 @@ const TrackPlayer = {
8966
setupPlayer: jest.fn(() => {
9067
// mark the mock as initialized so getPlaybackState will resolve
9168
initialized = true;
92-
notifyPlaybackState();
9369
return Promise.resolve();
9470
}),
9571
updateOptions: jest.fn(() => Promise.resolve()),
@@ -107,8 +83,6 @@ const TrackPlayer = {
10783
seekTo: jest.fn(async (sec: number) => {
10884
// clamp into [0, duration] and update internal position
10985
position = Math.max(0, Math.min(duration, sec));
110-
// notify listeners that position changed as a result of seeking
111-
notifyProgress();
11286
return Promise.resolve();
11387
}),
11488
play: jest.fn(async () => Promise.resolve()),

0 commit comments

Comments
 (0)