17 lines
619 B
TypeScript
17 lines
619 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { shouldCorrectVideoDrift } from '../lib/nowPlayingVideoSync';
|
|
|
|
describe('NowPlayingVideo drift correction', () => {
|
|
it('never seeks while unstarted, cued, or buffering', () => {
|
|
for (const state of [-1, 3, 5]) {
|
|
expect(shouldCorrectVideoDrift(state, 0, 30, 10_000)).toBe(false);
|
|
}
|
|
});
|
|
|
|
it('waits for cooldown and ignores small playing drift', () => {
|
|
expect(shouldCorrectVideoDrift(1, 0, 30, 1000)).toBe(false);
|
|
expect(shouldCorrectVideoDrift(1, 28, 30, 10_000)).toBe(false);
|
|
expect(shouldCorrectVideoDrift(1, 10, 30, 10_000)).toBe(true);
|
|
});
|
|
});
|