Files
ComfyUI_frontend/tests-ui/tests/litegraph/core/litegraph.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

49 lines
1.4 KiB
TypeScript

import { clamp } from 'es-toolkit/compat'
import { beforeEach, describe, expect, vi } from 'vitest'
import {
LGraphCanvas,
LiteGraph,
LiteGraphGlobal
} from '@/lib/litegraph/src/litegraph'
import { test } from './fixtures/testExtensions'
describe('Litegraph module', () => {
test('contains a global export', ({ expect }) => {
expect(LiteGraph).toBeInstanceOf(LiteGraphGlobal)
expect(LiteGraph.LGraphCanvas).toBe(LGraphCanvas)
})
test('has the same structure', ({ expect }) => {
const lgGlobal = new LiteGraphGlobal()
expect(lgGlobal).toMatchSnapshot('minLGraph')
})
test('clamps values', () => {
expect(clamp(-1.124, 13, 24)).toStrictEqual(13)
expect(clamp(Infinity, 18, 29)).toStrictEqual(29)
})
})
describe('Import order dependency', () => {
beforeEach(() => {
vi.resetModules()
})
test('Imports without error when entry point is imported first', async ({
expect
}) => {
async function importNormally() {
const entryPointImport = await import('@/lib/litegraph/src/litegraph')
const directImport = await import('@/lib/litegraph/src/LGraph')
// Sanity check that imports were cleared.
expect(Object.is(LiteGraph, entryPointImport.LiteGraph)).toBe(false)
expect(Object.is(LiteGraph.LGraph, directImport.LGraph)).toBe(false)
}
await expect(importNormally()).resolves.toBeUndefined()
})
})