forked from json-logic/json-logic-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodules.test.js
More file actions
17 lines (16 loc) · 710 Bytes
/
modules.test.js
File metadata and controls
17 lines (16 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { LogicEngine, AsyncLogicEngine } from './index.js'
const engines = [new LogicEngine(), new AsyncLogicEngine()]
describe('Trying out adding modules to the engine', () => {
engines.forEach((engine) => {
test('Add Math Module', async () => {
engine.addModule('Math', Math, { deterministic: true, sync: true })
expect(await engine.run({ 'Math.ceil': 2.5 })).toBe(3)
expect(await engine.run({ 'Math.floor': 2.5 })).toBe(2)
})
test('Add math module with empty name', async () => {
engine.addModule('', Math, { deterministic: true, sync: true })
expect(await engine.run({ ceil: 2.5 })).toBe(3)
expect(await engine.run({ floor: 2.5 })).toBe(2)
})
})
})