Files
ComfyUI_frontend/tests-ui/tests/litegraph/utils/widget.test.ts
snomiao 8bfb1009ce [style] migrate to @prettier/plugin-oxc for faster formatting
Replace @trivago/prettier-plugin-sort-imports with @prettier/plugin-oxc
and @ianvs/prettier-plugin-sort-imports for improved performance.

Changes:
- Add @prettier/plugin-oxc (Rust-based fast parser)
- Add @ianvs/prettier-plugin-sort-imports (import sorting compatible with oxc)
- Remove @trivago/prettier-plugin-sort-imports
- Update .prettierrc to use new plugins and compatible import order config
- Reformat all files with new plugin configuration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-19 00:02:04 +00:00

47 lines
1.2 KiB
TypeScript

import { describe, expect, test } from 'vitest'
import {
getWidgetStep,
type IWidgetOptions
} from '@/lib/litegraph/src/litegraph'
describe('getWidgetStep', () => {
test('should return step2 when available', () => {
const options: IWidgetOptions<unknown> = {
step2: 0.5,
step: 20
}
expect(getWidgetStep(options)).toBe(0.5)
})
test('should calculate from step when step2 is not available', () => {
const options: IWidgetOptions<unknown> = {
step: 20
}
expect(getWidgetStep(options)).toBe(2) // 20 * 0.1 = 2
})
test('should use default step value of 10 when neither step2 nor step is provided', () => {
const options: IWidgetOptions<unknown> = {}
expect(getWidgetStep(options)).toBe(1) // 10 * 0.1 = 1
})
// Zero value is not allowed for step, fallback to 1.
test('should handle zero values correctly', () => {
const optionsWithZeroStep2: IWidgetOptions<unknown> = {
step2: 0,
step: 20
}
expect(getWidgetStep(optionsWithZeroStep2)).toBe(2)
const optionsWithZeroStep: IWidgetOptions<unknown> = {
step: 0
}
expect(getWidgetStep(optionsWithZeroStep)).toBe(1)
})
})