@@ -30,7 +30,8 @@ describe('PackageMetadataLoader', () => {
3030 "lsd:importPaths": {
3131 "https://example.org/bundles/npm/@solid/community-server/^1.0.0/components/": "components/",
3232 "https://example.org/bundles/npm/@solid/community-server/^1.0.0/config/": "config/"
33- }
33+ },
34+ "types": "./index.d.ts"
3435}` ,
3536 } ;
3637 expect ( await loader . load ( '/' ) ) . toEqual ( {
@@ -46,6 +47,7 @@ describe('PackageMetadataLoader', () => {
4647 moduleIri : 'https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server' ,
4748 name : '@solid/community-server' ,
4849 version : '1.2.3' ,
50+ typesPath : Path . normalize ( '/index' ) ,
4951 } ) ;
5052 } ) ;
5153
@@ -114,5 +116,44 @@ describe('PackageMetadataLoader', () => {
114116 await expect ( loader . load ( '/' ) ) . rejects
115117 . toThrow ( new Error ( `Invalid package: Missing 'lsd:importPaths' in ${ Path . normalize ( '/package.json' ) } ` ) ) ;
116118 } ) ;
119+
120+ it ( 'should error when types is missing' , async ( ) => {
121+ resolutionContext . contentsOverrides = {
122+ [ Path . normalize ( '/package.json' ) ] : `{
123+ "name": "@solid/community-server",
124+ "lsd:module": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server",
125+ "lsd:components": "components/components.jsonld",
126+ "lsd:contexts": {
127+ "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld": "components/context.jsonld"
128+ },
129+ "lsd:importPaths": {
130+ "https://example.org/bundles/npm/@solid/community-server/^1.0.0/components/": "components/",
131+ "https://example.org/bundles/npm/@solid/community-server/^1.0.0/config/": "config/"
132+ }
133+ }` ,
134+ } ;
135+ 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' ) } ` ) ) ;
157+ } ) ;
117158 } ) ;
118159} ) ;
0 commit comments