Skip to content

Commit c1cf5ad

Browse files
committed
Add tests
1 parent 0093650 commit c1cf5ad

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

packages/definitions-parser/src/mocks.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,27 @@ console.log(jQuery);
242242
);
243243
jquery.set("tsconfig.json", tsconfig(["jquery-tests.ts"]));
244244

245+
const scoped = dt.pkgDir("wordpress__plugins");
246+
scoped.set(
247+
"index.d.ts",
248+
`// Type definitions for @wordpress/plguins
249+
// Project: https://github.com/WordPress/gutenberg/tree/master/packages/plugins
250+
// Definitions by: Derek Sifford <https://github.com/dsifford>
251+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
252+
`
253+
);
254+
scoped.set(
255+
"tsconfig.json",
256+
JSON.stringify({
257+
compilerOptions: {
258+
paths: {
259+
"@wordpress/*": ["wordpress__*"]
260+
}
261+
},
262+
files: ["index.d.ts"]
263+
})
264+
);
265+
245266
return dt;
246267
}
247268

packages/definitions-parser/test/definition-parser.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,9 @@ describe(getTypingInfo, () => {
9797
});
9898
});
9999
});
100+
101+
it("allows wildcard scope path mappings", () => {
102+
const dt = createMockDT();
103+
return expect(getTypingInfo("wordpress__plugins", dt.pkgFS("wordpress__plugins"))).resolves.toBeDefined();
104+
});
100105
});

packages/definitions-parser/test/parse-definitions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ testo({
2020
const log = quietLoggerWithErrors()[0];
2121
const defs = await parseDefinitions(createMockDT().fs, undefined, log);
2222
expect(defs.allNotNeeded().length).toBe(1);
23-
expect(defs.allTypings().length).toBe(4);
23+
expect(defs.allTypings().length).toBe(5);
2424
const j = defs.tryGetLatestVersion("jquery");
2525
expect(j).toBeDefined();
2626
expect(j!.fullNpmName).toContain("types");

0 commit comments

Comments
 (0)