bc-minecraft-bedrock-project
Version:
The typescript library responsible for reading/parsing minecraft bedrock data
43 lines • 1.44 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const json_path_1 = require("./json-path");
const entity = `{
"format_version": "1.16.0",
"minecraft:entity": {
"description": {
"identifier": "blockception:example",
"is_spawnable": true,
"is_summonable": true
},
"component_groups": {
},
"components": {
"minecraft:health": { "value": 10, "max": 10 },
"minecraft:behavior.look_at_player": { "probability": 1.0, "target_distance": 16 },
"minecraft:damage_sensor": {
"triggers": [
{ "cause": "all"}
]
}
},
"events": {
}
}
}`;
describe("JsonPath", () => {
const paths = [
{ path: "minecraft:entity", result: "minecraft:entity" },
{ path: "minecraft:entity/description", result: "description" },
{ path: "minecraft:entity/description/identifier", result: "identifier" },
{ path: "minecraft:entity\\description", result: "description" },
{ path: "minecraft:entity\\description/identifier", result: "identifier" },
];
paths.forEach(item => {
it(`should parse ${item.path} to location of ${item.result}`, () => {
const offset = json_path_1.JsonPath.resolve(entity, item.path);
const actual = entity.indexOf(item.result);
expect(offset).toEqual(actual);
});
});
});
//# sourceMappingURL=json-path.test.js.map