style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -1,54 +1,54 @@
import { describe, expect, test } from "bun:test";
import { lazySchema } from "../lazySchema";
import { describe, expect, test } from 'bun:test'
import { lazySchema } from '../lazySchema'
describe("lazySchema", () => {
test("returns a function", () => {
const factory = lazySchema(() => 42);
expect(typeof factory).toBe("function");
});
describe('lazySchema', () => {
test('returns a function', () => {
const factory = lazySchema(() => 42)
expect(typeof factory).toBe('function')
})
test("calls factory on first invocation", () => {
let callCount = 0;
test('calls factory on first invocation', () => {
let callCount = 0
const factory = lazySchema(() => {
callCount++;
return "result";
});
factory();
expect(callCount).toBe(1);
});
callCount++
return 'result'
})
factory()
expect(callCount).toBe(1)
})
test("returns cached result on subsequent invocations", () => {
const factory = lazySchema(() => ({ value: Math.random() }));
const first = factory();
const second = factory();
expect(first).toBe(second);
});
test('returns cached result on subsequent invocations', () => {
const factory = lazySchema(() => ({ value: Math.random() }))
const first = factory()
const second = factory()
expect(first).toBe(second)
})
test("factory is called only once", () => {
let callCount = 0;
test('factory is called only once', () => {
let callCount = 0
const factory = lazySchema(() => {
callCount++;
return "cached";
});
factory();
factory();
factory();
expect(callCount).toBe(1);
});
callCount++
return 'cached'
})
factory()
factory()
factory()
expect(callCount).toBe(1)
})
test("works with different return types", () => {
const numFactory = lazySchema(() => 123);
expect(numFactory()).toBe(123);
test('works with different return types', () => {
const numFactory = lazySchema(() => 123)
expect(numFactory()).toBe(123)
const arrFactory = lazySchema(() => [1, 2, 3]);
expect(arrFactory()).toEqual([1, 2, 3]);
});
const arrFactory = lazySchema(() => [1, 2, 3])
expect(arrFactory()).toEqual([1, 2, 3])
})
test("each call to lazySchema returns independent cache", () => {
const a = lazySchema(() => ({ id: "a" }));
const b = lazySchema(() => ({ id: "b" }));
expect(a()).not.toBe(b());
expect(a().id).toBe("a");
expect(b().id).toBe("b");
});
});
test('each call to lazySchema returns independent cache', () => {
const a = lazySchema(() => ({ id: 'a' }))
const b = lazySchema(() => ({ id: 'b' }))
expect(a()).not.toBe(b())
expect(a().id).toBe('a')
expect(b().id).toBe('b')
})
})