@@ -51,6 +51,74 @@ describe('PackageMetadataLoader', () => {
5151 } ) ;
5252 } ) ;
5353
54+ it ( 'should return with all required entries, but using typings' , async ( ) => {
55+ resolutionContext . contentsOverrides = {
56+ [ Path . normalize ( '/package.json' ) ] : `{
57+ "name": "@solid/community-server",
58+ "version": "1.2.3",
59+ "lsd:module": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server",
60+ "lsd:components": "components/components.jsonld",
61+ "lsd:contexts": {
62+ "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld": "components/context.jsonld"
63+ },
64+ "lsd:importPaths": {
65+ "https://example.org/bundles/npm/@solid/community-server/^1.0.0/components/": "components/",
66+ "https://example.org/bundles/npm/@solid/community-server/^1.0.0/config/": "config/"
67+ },
68+ "typings": "./index.d.ts"
69+ }` ,
70+ } ;
71+ expect ( await loader . load ( '/' ) ) . toEqual ( {
72+ componentsPath : Path . normalize ( '/components/components.jsonld' ) ,
73+ contexts : {
74+ 'https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld' :
75+ 'components/context.jsonld' ,
76+ } ,
77+ importPaths : {
78+ 'https://example.org/bundles/npm/@solid/community-server/^1.0.0/components/' : 'components/' ,
79+ 'https://example.org/bundles/npm/@solid/community-server/^1.0.0/config/' : 'config/' ,
80+ } ,
81+ moduleIri : 'https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server' ,
82+ name : '@solid/community-server' ,
83+ version : '1.2.3' ,
84+ typesPath : Path . normalize ( '/index' ) ,
85+ } ) ;
86+ } ) ;
87+
88+ it ( 'should return with all required entries, but using typings without extension' , async ( ) => {
89+ resolutionContext . contentsOverrides = {
90+ [ Path . normalize ( '/package.json' ) ] : `{
91+ "name": "@solid/community-server",
92+ "version": "1.2.3",
93+ "lsd:module": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server",
94+ "lsd:components": "components/components.jsonld",
95+ "lsd:contexts": {
96+ "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld": "components/context.jsonld"
97+ },
98+ "lsd:importPaths": {
99+ "https://example.org/bundles/npm/@solid/community-server/^1.0.0/components/": "components/",
100+ "https://example.org/bundles/npm/@solid/community-server/^1.0.0/config/": "config/"
101+ },
102+ "typings": "./index"
103+ }` ,
104+ } ;
105+ expect ( await loader . load ( '/' ) ) . toEqual ( {
106+ componentsPath : Path . normalize ( '/components/components.jsonld' ) ,
107+ contexts : {
108+ 'https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld' :
109+ 'components/context.jsonld' ,
110+ } ,
111+ importPaths : {
112+ 'https://example.org/bundles/npm/@solid/community-server/^1.0.0/components/' : 'components/' ,
113+ 'https://example.org/bundles/npm/@solid/community-server/^1.0.0/config/' : 'config/' ,
114+ } ,
115+ moduleIri : 'https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server' ,
116+ name : '@solid/community-server' ,
117+ version : '1.2.3' ,
118+ typesPath : Path . normalize ( '/index' ) ,
119+ } ) ;
120+ } ) ;
121+
54122 it ( 'should error on invalid JSON' , async ( ) => {
55123 resolutionContext . contentsOverrides = {
56124 [ Path . normalize ( '/package.json' ) ] : `{` ,
@@ -117,7 +185,7 @@ describe('PackageMetadataLoader', () => {
117185 . toThrow ( new Error ( `Invalid package: Missing 'lsd:importPaths' in ${ Path . normalize ( '/package.json' ) } ` ) ) ;
118186 } ) ;
119187
120- it ( 'should error when types is missing' , async ( ) => {
188+ it ( 'should error when types and typings is missing' , async ( ) => {
121189 resolutionContext . contentsOverrides = {
122190 [ Path . normalize ( '/package.json' ) ] : `{
123191 "name": "@solid/community-server",
@@ -133,27 +201,7 @@ describe('PackageMetadataLoader', () => {
133201}` ,
134202 } ;
135203 await expect ( loader . load ( '/' ) ) . rejects
136- . toThrow ( new Error ( `Invalid package: Missing 'types' in ${ Path . normalize ( '/package.json' ) } ` ) ) ;
137- } ) ;
138-
139- it ( 'should error when types does not end with .d.ts' , async ( ) => {
140- resolutionContext . contentsOverrides = {
141- [ Path . normalize ( '/package.json' ) ] : `{
142- "name": "@solid/community-server",
143- "lsd:module": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server",
144- "lsd:components": "components/components.jsonld",
145- "lsd:contexts": {
146- "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld": "components/context.jsonld"
147- },
148- "lsd:importPaths": {
149- "https://example.org/bundles/npm/@solid/community-server/^1.0.0/components/": "components/",
150- "https://example.org/bundles/npm/@solid/community-server/^1.0.0/config/": "config/"
151- },
152- "types": "index.ts"
153- }` ,
154- } ;
155- await expect ( loader . load ( '/' ) ) . rejects
156- . toThrow ( new Error ( `Invalid package: 'types' entry does not have '.d.ts' suffix in ${ Path . normalize ( '/package.json' ) } ` ) ) ;
204+ . toThrow ( new Error ( `Invalid package: Missing 'types' or 'typings' in ${ Path . normalize ( '/package.json' ) } ` ) ) ;
157205 } ) ;
158206 } ) ;
159207} ) ;
0 commit comments