import { describe, expect, it } from 'vitest';
import { nextIndex, prevIndex } from '~/player/playlist';
describe('nextIndex', () => {
it('advances within bounds', () => {
expect(nextIndex(0, 3, false)).toBe(1);
expect(nextIndex(1, 3, false)).toBe(2);
});
it('wraps to 0 at the end when loop is on', () => {
expect(nextIndex(2, 3, true)).toBe(0);
});
it('returns null at the end when loop is off', () => {
expect(nextIndex(2, 3, false)).toBeNull();
});
it('returns null for an empty list', () => {
expect(nextIndex(0, 0, true)).toBeNull();
});
});
describe('prevIndex', () => {
it('steps back within bounds', () => {
expect(prevIndex(2, 3, false)).toBe(1);
});
it('wraps to the last index when loop is on', () => {
expect(prevIndex(0, 3, true)).toBe(2);
});
it('returns null at the start when loop is off', () => {
expect(prevIndex(0, 3, false)).toBeNull();
});
});