Create standalone browser port of LTX Athena with authenticated native API transport
This commit is contained in:
commit
1333b0c36b
202 files changed
+63054
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { describe, it } from 'node:test'
|
||||
import {
|
||||
DEFAULT_KEYFRAME_STRENGTH,
|
||||
formatKeyframeStrength,
|
||||
nudgeKeyframeStrength,
|
||||
strengthFromPointer,
|
||||
} from './keyframe-strength.ts'
|
||||
|
||||
describe('strengthFromPointer', () => {
|
||||
const rail = { top: 10, height: 100 }
|
||||
|
||||
it('maps the top of the rail to full strength', () => {
|
||||
assert.equal(strengthFromPointer(10, rail), 1)
|
||||
})
|
||||
|
||||
it('maps the bottom of the rail to zero strength', () => {
|
||||
assert.equal(strengthFromPointer(110, rail), 0)
|
||||
})
|
||||
|
||||
it('maps the midpoint to 0.5', () => {
|
||||
assert.equal(strengthFromPointer(60, rail), 0.5)
|
||||
})
|
||||
|
||||
it('clamps above the rail to 1 and below it to 0', () => {
|
||||
assert.equal(strengthFromPointer(0, rail), 1)
|
||||
assert.equal(strengthFromPointer(200, rail), 0)
|
||||
})
|
||||
|
||||
it('returns the new-still default when the rail has no height', () => {
|
||||
assert.equal(strengthFromPointer(10, { top: 10, height: 0 }), DEFAULT_KEYFRAME_STRENGTH)
|
||||
})
|
||||
})
|
||||
|
||||
describe('nudgeKeyframeStrength', () => {
|
||||
it('steps by five percent', () => {
|
||||
assert.equal(nudgeKeyframeStrength(0.7, 1), 0.75)
|
||||
assert.equal(nudgeKeyframeStrength(0.7, -1), 0.65)
|
||||
})
|
||||
|
||||
it('clamps at 0 and 1', () => {
|
||||
assert.equal(nudgeKeyframeStrength(0.02, -1), 0)
|
||||
assert.equal(nudgeKeyframeStrength(0.98, 1), 1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('formatKeyframeStrength', () => {
|
||||
it('renders owned strength as a percent', () => {
|
||||
assert.equal(formatKeyframeStrength(0.7), '70%')
|
||||
assert.equal(formatKeyframeStrength(0), '0%')
|
||||
assert.equal(formatKeyframeStrength(1), '100%')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user