- Closes #2556 - Closes #2450 **Key intended features:** - go2rtc compatible - 100% test coverage to significantly improve ability to test, maintain and work around browser weirdnesses (e.g. Safari). - Written from the ground up in the style of the rest of the project. **To use:** - Change `live_provider` from `go2rtc` to `go2rtc-experimental`.
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { Generation } from '../../../src/utils/concurrency/generation';
|
|
|
|
describe('Generation', () => {
|
|
it('should treat a fresh snapshot as current', () => {
|
|
const generation = new Generation();
|
|
|
|
expect(generation.isCurrent(generation.current())).toBe(true);
|
|
});
|
|
|
|
it('should keep a snapshot current across further snapshots', () => {
|
|
const generation = new Generation();
|
|
const token = generation.current();
|
|
|
|
generation.current();
|
|
|
|
expect(generation.isCurrent(token)).toBe(true);
|
|
});
|
|
|
|
it('should invalidate outstanding snapshots', () => {
|
|
const generation = new Generation();
|
|
const token = generation.current();
|
|
|
|
generation.invalidate();
|
|
|
|
expect(generation.isCurrent(token)).toBe(false);
|
|
});
|
|
|
|
it('should invalidate prior tokens when starting a new operation', () => {
|
|
const generation = new Generation();
|
|
const first = generation.next();
|
|
const second = generation.next();
|
|
|
|
expect(generation.isCurrent(first)).toBe(false);
|
|
expect(generation.isCurrent(second)).toBe(true);
|
|
});
|
|
});
|