|
| 1 | +import { beforeAll, describe, expect, it } from "vitest"; |
| 2 | +import { CooklangParser } from "../src/parser"; |
| 3 | + |
| 4 | +it("returns version number", () => { |
| 5 | + const parser = new CooklangParser(); |
| 6 | + expect(parser.version).toBeDefined(); |
| 7 | +}); |
| 8 | + |
| 9 | +describe("create and use instance", () => { |
| 10 | + let recipe: CooklangParser; |
| 11 | + beforeAll(() => { |
| 12 | + const recipeString = "hello"; |
| 13 | + recipe = new CooklangParser(recipeString); |
| 14 | + }); |
| 15 | + |
| 16 | + it("returns pretty stringified recipe", () => { |
| 17 | + expect(recipe.renderPrettyString()).toEqual("hello"); |
| 18 | + }); |
| 19 | + |
| 20 | + it("returns basic html recipe", () => { |
| 21 | + expect(recipe.renderPrettyString()).toEqual("hello"); |
| 22 | + }); |
| 23 | + |
| 24 | + it("returns metadata list", () => { |
| 25 | + expect(recipe.metadata).toEqual({}); |
| 26 | + }); |
| 27 | + |
| 28 | + it("returns ingredients list", () => { |
| 29 | + expect(recipe.ingredients).toEqual(new Map()); |
| 30 | + }); |
| 31 | + |
| 32 | + it("returns sections list", () => { |
| 33 | + expect(recipe.sections).toEqual([]); |
| 34 | + }); |
| 35 | + |
| 36 | + it("returns cookware list", () => { |
| 37 | + expect(recipe.cookware).toEqual(new Map()); |
| 38 | + }); |
| 39 | + |
| 40 | + it("returns timers list", () => { |
| 41 | + expect(recipe.timers).toEqual([]); |
| 42 | + }); |
| 43 | +}); |
| 44 | + |
| 45 | +describe("functional", () => { |
| 46 | + const parser = new CooklangParser(); |
| 47 | + const recipe = "hello"; |
| 48 | + it("returns pretty stringified recipe", () => { |
| 49 | + const parsedRecipe = parser.renderPrettyString(recipe); |
| 50 | + expect(parsedRecipe).toEqual("hello"); |
| 51 | + }); |
| 52 | + |
| 53 | + it("returns basic html recipe", () => { |
| 54 | + const parsedRecipe = parser.renderHTML(recipe); |
| 55 | + expect(parsedRecipe).toEqual("hello"); |
| 56 | + }); |
| 57 | + |
| 58 | + it("returns full parse of recipe string", () => { |
| 59 | + const parsedRecipe = parser.parse(recipe); |
| 60 | + expect(parsedRecipe).toEqual({ |
| 61 | + cookware: new Map(), |
| 62 | + ingredients: new Map(), |
| 63 | + metadata: {}, |
| 64 | + sections: [], |
| 65 | + timers: [], |
| 66 | + }); |
| 67 | + }); |
| 68 | + |
| 69 | + it("returns metadata list", () => { |
| 70 | + const parsedRecipe = parser.parse(recipe); |
| 71 | + expect(parsedRecipe.metadata).toEqual({}); |
| 72 | + }); |
| 73 | + |
| 74 | + it("returns ingredients list", () => { |
| 75 | + const parsedRecipe = parser.parse(recipe); |
| 76 | + expect(parsedRecipe.ingredients).toEqual(new Map()); |
| 77 | + }); |
| 78 | + |
| 79 | + it("returns sections list", () => { |
| 80 | + const parsedRecipe = parser.parse(recipe); |
| 81 | + expect(parsedRecipe.sections).toEqual([]); |
| 82 | + }); |
| 83 | + |
| 84 | + it("returns cookware list", () => { |
| 85 | + const parsedRecipe = parser.parse(recipe); |
| 86 | + expect(parsedRecipe.cookware).toEqual(new Map()); |
| 87 | + }); |
| 88 | + |
| 89 | + it("returns timers list", () => { |
| 90 | + const parsedRecipe = parser.parse(recipe); |
| 91 | + expect(parsedRecipe.timers).toEqual([]); |
| 92 | + }); |
| 93 | +}); |
0 commit comments