File tree Expand file tree Collapse file tree
packages/definitions-parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -214,6 +214,32 @@ export * from "moment"`
214214 hasDependency . set ( "tsconfig.json" , tsconfig ( [ "has-dependency-tests.ts" ] ) ) ;
215215 hasDependency . set ( "package.json" , `{ "private": true, "dependencies": { "moment": "*" } }` ) ;
216216
217+ const hasPathMapping = dt . pkgDir ( "has-path-mapping" ) ;
218+ hasPathMapping . set (
219+ "index.d.ts" ,
220+ `// Type definitions for has-path-mapping
221+ // Project: https://example.com
222+ // Definitions by: Nobody <https://example.com>
223+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
224+ `
225+ ) ;
226+ hasPathMapping . set (
227+ "has-path-mapping-tests.ts" ,
228+ `import "jquery";
229+ `
230+ ) ;
231+ hasPathMapping . set (
232+ "tsconfig.json" ,
233+ JSON . stringify ( {
234+ compilerOptions : {
235+ paths : {
236+ jquery : [ "jquery/v1" ]
237+ }
238+ } ,
239+ files : [ "index.d.ts" , "has-path-mapping-tests.ts" ]
240+ } )
241+ ) ;
242+
217243 const jquery = dt . pkgDir ( "jquery" ) ;
218244 jquery . set (
219245 "JQuery.d.ts" ,
Original file line number Diff line number Diff line change 11import { createMockDT } from "../src/mocks" ;
22import { getTypingInfo } from "../src/lib/definition-parser" ;
3- import { TypingsVersions } from "../src/packages" ;
3+ import { AllPackages , TypingsVersions } from "../src/packages" ;
4+ import { parseDefinitions } from "../src/parse-definitions" ;
5+ import { quietLoggerWithErrors } from "@definitelytyped/utils" ;
6+
7+ describe ( AllPackages , ( ) => {
8+ let allPackages : AllPackages ;
9+
10+ beforeAll ( async ( ) => {
11+ const dt = createMockDT ( ) ;
12+ dt . addOldVersionOfPackage ( "jquery" , "1" ) ;
13+ const [ log ] = quietLoggerWithErrors ( ) ;
14+ allPackages = await parseDefinitions ( dt . fs , undefined , log ) ;
15+ } ) ;
16+
17+ it ( "applies path mappings to test dependencies" , ( ) => {
18+ const pkg = allPackages . tryGetLatestVersion ( "has-path-mapping" ) ! ;
19+ expect ( Array . from ( allPackages . allDependencyTypings ( pkg ) , ( { id } ) => id ) ) . toEqual ( [
20+ { name : "jquery" , version : { major : 1 , minor : 0 } }
21+ ] ) ;
22+ } ) ;
23+ } ) ;
424
525describe ( TypingsVersions , ( ) => {
626 let versions : TypingsVersions ;
Original file line number Diff line number Diff 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" ) ;
You can’t perform that action at this time.
0 commit comments