• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1namespace ts {
2  const fs: typeof import("fs") = require("fs");
3  const path: typeof import("path") = require("path");
4  const childProcess: typeof import("child_process") = require("child_process");
5
6  const rootPath = path.resolve(__dirname);
7
8  function tscEtsCompile() {
9    const tsconfigPath = path.join(rootPath, "../../tests/dets/tsconfig.json");
10    const tscpath = path.join(rootPath, "../../lib/tsc.js");
11
12    const cmd = "node "+ tscpath + " -p " + tsconfigPath;
13
14    childProcess.exec(cmd, {
15      maxBuffer: 1 * 1024 * 1024,
16      cwd: undefined
17    }, (error, stdout, stderr) => {
18        if (error) {
19          console.log(cmd);
20          console.log("==> error " + JSON.stringify(error));
21          console.log("==> stdout " + String(stdout));
22          console.log("==> stderr " + String(stderr));
23          console.log("\r\n");
24          return;
25        }
26    });
27  }
28
29  function getActualAndExpect(caseName: string) {
30    const actualDeclarationPath = path.join(rootPath, "../../tests/dets/baselines/local", caseName);
31    const expectedDeclarationPath = path.join(rootPath, "../../tests/dets/baselines/reference", caseName);
32
33    const actualDeclaration = fs.readFileSync(actualDeclarationPath, "utf-8");
34    const expectedDeclaration = fs.readFileSync(expectedDeclarationPath, "utf-8");
35    return { actualDeclaration, expectedDeclaration };
36  }
37  describe("unittests:: tsc:: run ets tests::", () => {
38      tscEtsCompile();
39
40      it("customDecorator.ets", () => {
41        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("customDecorator.d.ets");
42        expect(expectedDeclaration).to.be.equal(actualDeclaration);
43      });
44
45      it("decoratorWithParameters.ets", () => {
46        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("decoratorWithParameters.d.ets");
47        expect(expectedDeclaration).to.be.equal(actualDeclaration);
48      });
49
50      it("dynamicallyBuildUIElements.ets", () => {
51        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("dynamicallyBuildUIElements.d.ets");
52        expect(expectedDeclaration).to.be.equal(actualDeclaration);
53      });
54
55      it("functionAndClassWithDecorator.ets", () => {
56        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("functionAndClassWithDecorator.d.ets");
57        expect(expectedDeclaration).to.be.equal(actualDeclaration);
58      });
59
60      it("functionWithDecorators.ets", () => {
61        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("functionWithDecorators.d.ets");
62        expect(expectedDeclaration).to.be.equal(actualDeclaration);
63      });
64
65      it("limitationAndExtension.ets", () => {
66        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("limitationAndExtension.d.ets");
67        expect(expectedDeclaration).to.be.equal(actualDeclaration);
68      });
69
70      it("renderControl.ets", () => {
71        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("renderControl.d.ets");
72        expect(expectedDeclaration).to.be.equal(actualDeclaration);
73      });
74
75      it("statusManagementOfApplicationLevelVariables.ets", () => {
76        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("statusManagementOfApplicationLevelVariables.d.ets");
77        expect(expectedDeclaration).to.be.equal(actualDeclaration);
78      });
79
80      it("statusManagementOfPageLevelVariables.ets", () => {
81        const {actualDeclaration, expectedDeclaration} = getActualAndExpect("statusManagementOfPageLevelVariables.d.ets");
82        expect(expectedDeclaration).to.be.equal(actualDeclaration);
83      });
84
85      it("targetEtsExample.ets", () => {
86          const { actualDeclaration, expectedDeclaration } = getActualAndExpect("targetEtsExample.d.ets");
87          expect(expectedDeclaration).to.be.equal(actualDeclaration);
88      });
89  });
90}
91