mirror of
https://github.com/thepeacockproject/StateMachineParser.git
synced 2026-11-24 13:12:35 -10:00
47 lines
1.0 KiB
JavaScript
47 lines
1.0 KiB
JavaScript
const { test } = require("../src/index")
|
|
|
|
const data = {
|
|
Inarray1: [
|
|
{
|
|
$inarray: {
|
|
in: "$Value.Objs",
|
|
"?": {
|
|
$eq: ["$.#", "quiet"],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Value: {
|
|
Objs: ["the", "world", "is", "quiet", "here"],
|
|
},
|
|
},
|
|
],
|
|
Inarray2: [
|
|
{
|
|
$inarray: {
|
|
in: "$Value.Objs",
|
|
"?": {
|
|
$eq: ["$.#", "clarinet"],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Value: {
|
|
Objs: ["flute", "saxophone", "trumpet", "bass guitar", "drums"],
|
|
},
|
|
},
|
|
],
|
|
}
|
|
|
|
describe("$inarray", () => {
|
|
it("can find a string in a context array", () => {
|
|
const [sm, globals] = data.Inarray1
|
|
expect(test(sm, globals)).toBe(true)
|
|
})
|
|
|
|
it("returns false if the item isn't present", () => {
|
|
const [sm, globals] = data.Inarray2
|
|
expect(test(sm, globals)).toBe(false)
|
|
})
|
|
})
|