51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
|
import { MediaSet } from './generated/media_set';
|
||
|
import { stateReducer, State } from './AppState';
|
||
|
import { from } from 'rxjs';
|
||
|
import { PlayState } from './Player';
|
||
|
import { CanvasLogicalWidth } from './HudCanvasState';
|
||
|
|
||
|
const initialState: State = {
|
||
|
selection: { start: 0, end: 0 },
|
||
|
viewport: { start: 0, end: 441000 },
|
||
|
overviewPeaks: from([]),
|
||
|
waveformPeaks: from([]),
|
||
|
selectionCanvas: { start: 0, end: 0 },
|
||
|
viewportCanvas: { start: 0, end: CanvasLogicalWidth },
|
||
|
position: { currentTime: 0, frame: 0, percent: 0 },
|
||
|
audioSrc: '',
|
||
|
videoSrc: '',
|
||
|
currentTime: 0,
|
||
|
playState: PlayState.Paused,
|
||
|
};
|
||
|
|
||
|
describe('stateReducer', () => {
|
||
|
describe('mediasetloaded', () => {
|
||
|
describe.each([
|
||
|
{
|
||
|
name: 'with a normal length media set',
|
||
|
audioFrames: 4410000,
|
||
|
wantViewportFrames: 220500,
|
||
|
},
|
||
|
{
|
||
|
name: 'with a very short media set',
|
||
|
audioFrames: 44100,
|
||
|
wantViewportFrames: 2200,
|
||
|
},
|
||
|
])('mousedown', ({ name, audioFrames, wantViewportFrames }) => {
|
||
|
test(name, () => {
|
||
|
const mediaSet = MediaSet.fromPartial({
|
||
|
id: '123',
|
||
|
audioFrames: audioFrames,
|
||
|
});
|
||
|
const state = stateReducer(
|
||
|
{ ...initialState },
|
||
|
{ type: 'mediasetloaded', mediaSet: mediaSet }
|
||
|
);
|
||
|
expect(state.mediaSet).toBe(mediaSet);
|
||
|
expect(state.viewport.start).toEqual(0);
|
||
|
expect(state.viewport.end).toEqual(wantViewportFrames);
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|