| 1 |
import { test } from 'node:test'; |
| 2 |
import assert from 'node:assert/strict'; |
| 3 |
import { wrapIndex } from './carousel.logic.ts'; |
| 4 |
|
| 5 |
test('wrapIndex is identity within range', () => { |
| 6 |
assert.equal(wrapIndex(0, 3), 0); |
| 7 |
assert.equal(wrapIndex(2, 3), 2); |
| 8 |
}); |
| 9 |
|
| 10 |
test('wrapIndex wraps forward past the last frame to the first', () => { |
| 11 |
assert.equal(wrapIndex(3, 3), 0); |
| 12 |
assert.equal(wrapIndex(4, 3), 1); |
| 13 |
}); |
| 14 |
|
| 15 |
test('wrapIndex wraps backward past the first frame to the last', () => { |
| 16 |
assert.equal(wrapIndex(-1, 3), 2); |
| 17 |
assert.equal(wrapIndex(-2, 3), 1); |
| 18 |
}); |
| 19 |
|