mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -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')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user