fix: fix lint && typecheck

This commit is contained in:
xingyu4j
2026-05-18 16:50:14 +08:00
parent 5bbdcffb97
commit 0c1b737325
23 changed files with 188 additions and 213 deletions

View File

@@ -34,7 +34,9 @@ describe('stateHandler', () => {
}, 10);
// 等待过程中,期望 Promise 被 reject
await expect(handler.waitForCondition()).rejects.toThrow();
await expect(handler.waitForCondition()).rejects.toThrow(
'Condition was set to false',
);
expect(handler.isConditionTrue()).toBe(false);
});

View File

@@ -138,8 +138,10 @@ describe('getNestedValue', () => {
expect(result).toBe(2);
});
it('should return the entire object if path is empty', () => {
expect(() => getNestedValue(data, '')()).toThrow();
it('should throw if path is empty', () => {
expect(() => getNestedValue(data, '')).toThrow(
'Path must be a non-empty string',
);
});
it('should handle paths with array indexes', () => {

View File

@@ -1,6 +1,6 @@
export class StateHandler {
private condition: boolean = false;
private rejectCondition: (() => void) | null = null;
private rejectCondition: ((reason?: Error) => void) | null = null;
private resolveCondition: (() => void) | null = null;
isConditionTrue(): boolean {
@@ -16,7 +16,7 @@ export class StateHandler {
setConditionFalse() {
this.condition = false;
if (this.rejectCondition) {
this.rejectCondition();
this.rejectCondition(new Error('Condition was set to false'));
this.clearPromises();
}
}