Add test coverage for positionchanged event
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
29129afe90
commit
669afcf6d9
|
@ -242,13 +242,13 @@ describe('stateReducer', () => {
|
|||
event: {
|
||||
mode: SelectionMode.Normal,
|
||||
prevMode: SelectionMode.Selecting,
|
||||
selection: { x1: 1001, x2: 1200 },
|
||||
selection: { x1: 1100, x2: 1200 },
|
||||
},
|
||||
playState: PlayState.Playing,
|
||||
position: { frame: 22000, currentTime: 0.4988, percent: 4.98 },
|
||||
viewport: { start: 0, end: 88200 },
|
||||
wantSelection: { start: 44144, end: 52920 },
|
||||
wantCurrentTime: 1.000997732426304,
|
||||
wantSelection: { start: 48510, end: 52920 },
|
||||
wantCurrentTime: 1.1,
|
||||
},
|
||||
{
|
||||
name: 'playing, selection is ending, currFrame is within selection',
|
||||
|
@ -312,4 +312,76 @@ describe('stateReducer', () => {
|
|||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('positionchanged', () => {
|
||||
describe.each([
|
||||
{
|
||||
name: 'playing, 48k',
|
||||
audioSampleRate: 48000,
|
||||
newCurrentTime: 0.02,
|
||||
position: { frame: 0, currentTime: 0, percent: 0 },
|
||||
selection: { start: 0, end: 0 },
|
||||
wantPosition: {
|
||||
frame: 960,
|
||||
currentTime: 0.02,
|
||||
percent: 0.21768707482993196,
|
||||
},
|
||||
wantCurrentTime: undefined,
|
||||
wantPlayState: PlayState.Playing,
|
||||
},
|
||||
{
|
||||
name: 'playing, 44.1k',
|
||||
audioSampleRate: 44100,
|
||||
newCurrentTime: 8.51,
|
||||
position: { frame: 360000, currentTime: 8.16, percent: 81.6 },
|
||||
selection: { start: 0, end: 0 },
|
||||
wantPosition: { frame: 375291, currentTime: 8.51, percent: 85.1 },
|
||||
wantCurrentTime: undefined,
|
||||
wantPlayState: PlayState.Playing,
|
||||
},
|
||||
{
|
||||
name: 'playing, passed selection end',
|
||||
audioSampleRate: 44100,
|
||||
newCurrentTime: 8.51,
|
||||
position: { frame: 360000, currentTime: 8.16, percent: 81.6 },
|
||||
selection: { start: 22050, end: 375290 },
|
||||
wantPosition: { frame: 375291, currentTime: 8.51, percent: 85.1 },
|
||||
wantCurrentTime: 0.5,
|
||||
wantPlayState: PlayState.Paused,
|
||||
},
|
||||
])(
|
||||
'$name',
|
||||
({
|
||||
audioSampleRate,
|
||||
newCurrentTime,
|
||||
position,
|
||||
selection,
|
||||
wantPosition,
|
||||
wantCurrentTime,
|
||||
wantPlayState,
|
||||
}) => {
|
||||
it('generates the expected state', () => {
|
||||
const mediaSet = MediaSet.fromPartial({
|
||||
id: '123',
|
||||
audioFrames: 441000,
|
||||
audioSampleRate: audioSampleRate,
|
||||
});
|
||||
const state = stateReducer(
|
||||
{
|
||||
...initialState,
|
||||
playState: PlayState.Playing,
|
||||
mediaSet,
|
||||
position,
|
||||
selection,
|
||||
},
|
||||
{ type: 'positionchanged', currentTime: newCurrentTime }
|
||||
);
|
||||
|
||||
expect(state.position).toEqual(wantPosition);
|
||||
expect(state.playState).toEqual(wantPlayState);
|
||||
expect(state.currentTime).toEqual(wantCurrentTime);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue