feat: cut clip from Player mode (X/Z keys, scissors button)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
43
tests/lib/utils/clipRange.test.ts
Normal file
43
tests/lib/utils/clipRange.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { computeQuickClipRange } from '$lib/utils/clipRange';
|
||||
|
||||
describe('computeQuickClipRange', () => {
|
||||
it('returns null when duration is 0', () => {
|
||||
expect(computeQuickClipRange(5, 0, 'at')).toBeNull();
|
||||
});
|
||||
|
||||
it('"at" creates clip from currentTime to currentTime+10', () => {
|
||||
const result = computeQuickClipRange(30, 120, 'at');
|
||||
expect(result).toEqual({ start: 30, end: 40 });
|
||||
});
|
||||
|
||||
it('"before" creates clip from currentTime-10 to currentTime', () => {
|
||||
const result = computeQuickClipRange(30, 120, 'before');
|
||||
expect(result).toEqual({ start: 20, end: 30 });
|
||||
});
|
||||
|
||||
it('"at" clamps end to duration', () => {
|
||||
const result = computeQuickClipRange(115, 120, 'at');
|
||||
expect(result).toEqual({ start: 115, end: 120 });
|
||||
});
|
||||
|
||||
it('"before" clamps start to 0', () => {
|
||||
const result = computeQuickClipRange(3, 120, 'before');
|
||||
expect(result).toEqual({ start: 0, end: 3 });
|
||||
});
|
||||
|
||||
it('accepts custom clip duration', () => {
|
||||
const result = computeQuickClipRange(50, 120, 'at', 20);
|
||||
expect(result).toEqual({ start: 50, end: 70 });
|
||||
});
|
||||
|
||||
it('"at" at time 0 works', () => {
|
||||
const result = computeQuickClipRange(0, 120, 'at');
|
||||
expect(result).toEqual({ start: 0, end: 10 });
|
||||
});
|
||||
|
||||
it('"before" at exact duration works', () => {
|
||||
const result = computeQuickClipRange(120, 120, 'before');
|
||||
expect(result).toEqual({ start: 110, end: 120 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user