Skip to content

Commit ae3482e

Browse files
author
Cache Hamm
committed
Add ts types for path-resolver engine option
1 parent 07ee3d6 commit ae3482e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

test/engine-fact.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,14 @@ describe('Engine: fact evaluation', () => {
284284

285285
engine = engineFactory([], { pathResolver })
286286
const rule = factories.rule({ conditions, event })
287-
await engine.run()
288287
engine.addRule(rule)
289288
engine.on('success', successSpy)
290289
engine.on('failure', failureSpy)
290+
291291
await engine.run(fact)
292+
292293
expect(successSpy).to.have.been.calledWith(event)
293-
expect(failureSpy).to.not.have.been.calledWith(event)
294+
expect(failureSpy).to.not.have.been.called()
294295
})
295296
})
296297
})

types/index.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface EngineOptions {
2-
allowUndefinedFacts: boolean;
3-
pathResolver: string;
2+
allowUndefinedFacts?: boolean;
3+
pathResolver?: PathResolver;
44
}
55

66
export interface EngineResult {
@@ -94,6 +94,11 @@ export interface Event {
9494
params?: Record<string, any>;
9595
}
9696

97+
export type PathResolver = (
98+
value: object,
99+
path: string,
100+
) => any;
101+
97102
export type EventHandler = (
98103
event: Event,
99104
almanac: Almanac,

0 commit comments

Comments
 (0)