Something went wrong on our end
Select Git revision
pnpm-lock.yaml
-
Volker Schukai authoredVolker Schukai authored
pathfinder.mjs 12.20 KiB
"use strict";
import {expect} from "chai"
import {Pathfinder} from "../../../source/data/pathfinder.mjs";
describe('Pathfinder', function () {
let convertMapResult = function (r) {
if (r instanceof Map) {
r = Object.fromEntries(r);
if (r instanceof Array) {
r = r.map((e) => {
return convertMapResult(e);
})
} else if (typeof r === "object") {
for (const [k, o] of Object.entries(r)) {
r[k] = convertMapResult(o);
}
}
}
return r;
}
describe('with Wildcard and Iterations', function () {
let pf, obj;
beforeEach(function () {
obj = {
a: [
{
b: [
{
c: "1-1"
},
{
c: "1-2"
}
],
d: '!'
},
{
b: [
{
c: "2-1"
},
{
c: "2-2"
}
],
d: '?'
}
]
}
pf = new Pathfinder(obj);
});
[
['a.*.b.*', '{"0":{"0":{"c":"1-1"},"1":{"c":"1-2"}},"1":{"0":{"c":"2-1"},"1":{"c":"2-2"}}}'],
['a.*.b', '{"0":[{"c":"1-1"},{"c":"1-2"}],"1":[{"c":"2-1"},{"c":"2-2"}]}'],
['a.1.b', '[{"c":"2-1"},{"c":"2-2"}]'],
['a.0.b', '[{"c":"1-1"},{"c":"1-2"}]'],
].forEach(function (data) {
let a = data.shift()
let b = data.shift()