/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import * as fs from "fs" import { getMetaForInkStoryPath } from "../dist/ink-utils.module" import { Compiler } from "inkjs/compiler/Compiler" import * as path from "path" const hoistStory = (storyFile) => { return new Compiler(fs.readFileSync(path.resolve("test", "data", storyFile), "utf-8")).Compile() } describe("getMetaForInkStoryPath", () => { test("it should retrieve empty meta for a default knot", () => { const story = hoistStory("no-knots.ink") const meta = getMetaForInkStoryPath(story, "") expect(meta).toStrictEqual({}) }) test("it should retrieve correct metadata for knots", () => { const story = hoistStory("metadata-on-knots.ink") const metaKnot1 = getMetaForInkStoryPath(story, "knot1") expect(metaKnot1).toStrictEqual({ TAG: 1, JSON: 2, }) const metaKnot2 = getMetaForInkStoryPath(story, "knot2") expect(metaKnot2).toStrictEqual({ TAG: 3 }) const metaKnot3 = getMetaForInkStoryPath(story, "knot3") expect(metaKnot3).toEqual({ STRINGS: "should also work", _: Array ["meta doesn't know what to do with this tag so it'll dump it into the _ bucket"] }) }) })