var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import { createMockEngine } from "../utils";
import { expect } from "chai";
describe(__filename + "#", () => {
    it("can parse a @desc", () => __awaiter(void 0, void 0, void 0, function* () {
        const graph = {
            "/entry.pc": `
        <!--
          @desc "some description"
        -->
        <div />

        <!--
          okay
        -->



        something
      `
        };
        const engine = yield createMockEngine(graph);
        const result = engine.run("/entry.pc");
        expect(result.preview.children[0].annotations.values.desc.value).to.eql("some description");
    }));
    it(`Can add metadata to an instance`, () => __awaiter(void 0, void 0, void 0, function* () {
        const graph = {
            "/entry.pc": `
        <span component as="Test">
          Hello
        </span>

        <!--
          @desc "abc"
        -->

        <Test />
      `
        };
        const engine = yield createMockEngine(graph);
        const result = engine.run("/entry.pc");
        expect(result.preview.children[0].annotations.values.desc.value).to.eql("abc");
    }));
    it(`Can add metadata to an imported instance`, () => __awaiter(void 0, void 0, void 0, function* () {
        const graph = {
            "/entry.pc": `
        <import src="/module.pc" as="mod" />

        <!--
          @desc "abc"
        -->

        <mod.Test />
      `,
            "/module.pc": `
        <span export component as="Test">
          Hello
        </span>
      `
        };
        const engine = yield createMockEngine(graph);
        const result = engine.run("/entry.pc");
        expect(result.preview.children[0].annotations.values.desc.value).to.eql("abc");
    }));
    it(`properly updates annotations`, () => __awaiter(void 0, void 0, void 0, function* () {
        const graph = {
            "/entry.pc": `
        <!--
          @frame "a"
        -->
        hello
      `
        };
        const engine = yield createMockEngine(graph);
        const result = yield engine.run("/entry.pc");
        expect(result.preview.children[0].annotations.values.frame.value).to.eql("a");
        engine.updateVirtualFileContent("/entry.pc", `
    <!--
      @frame "b"
    -->
    hello
  `);
        const result2 = yield engine.run("/entry.pc");
        expect(result2.preview.children[0].annotations.values.frame.value).to.eql("b");
    }));
});
