Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Add test for expression-file
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Apr 22, 2021
1 parent b18621e commit 54ed1d4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions baselines/requireJquery.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const requireJquery: string;

2 changes: 2 additions & 0 deletions baselines/simple.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const simple: string;

3 changes: 3 additions & 0 deletions tests/fixtures/require-jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const jqeury = require("jquery")

exports.jqeury = jqeury;
1 change: 1 addition & 0 deletions tests/fixtures/simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.test = 1
14 changes: 14 additions & 0 deletions tests/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const expressions: { [s: string]: any } = {
someClass: MyClass,
};

const expressionFiles: { [s: string]: any } = {
simple: path.join(__dirname, "fixtures", "simple.js"),
requireJquery: path.join(__dirname, "fixtures", "require-jquery.js"),
};

function checkDeclarationBaseline(name: string, content: string) {
const filename = path.join(__dirname, `../../baselines/${name}`);
const existing = fs.existsSync(filename) ? fs.readFileSync(filename, 'utf-8') : '<none>';
Expand All @@ -63,3 +68,12 @@ describe("Expression tests", () => {
});
}
});

describe("Expression file test", () => {
for (const key of Object.keys(expressionFiles)) {
it(`Generates the same declaration for ${key}`, () => {
const result = tsg.generateIdentifierDeclarationFile(key!, expressionFiles[key!]);
checkDeclarationBaseline(`${key}.d.ts`, result);
});
}
});

0 comments on commit 54ed1d4

Please sign in to comment.