@@ -28,66 +28,68 @@ const {
2828 Contrib,
2929} = require ( '../../' )
3030
31- suite ( 'unit: Contrib.FromNodePackageJson.Utils.defaultRegistryMatcher' , ( ) => {
32- test ( 'matches pure domain' , ( ) => {
33- const actual = Contrib . FromNodePackageJson . Utils . defaultRegistryMatcher . test ( 'https://registry.npmjs.org' )
34- assert . strictEqual ( actual , true )
35- } )
36- test ( 'matches with path' , ( ) => {
37- const actual = Contrib . FromNodePackageJson . Utils . defaultRegistryMatcher . test ( 'https://registry.npmjs.org/foo/bar' )
38- assert . strictEqual ( actual , true )
39- } )
40- suite ( 'not match unexpected' , ( ) => {
41- for ( const c of [
42- 'https://my-own=registry.local' ,
43- 'https://registry.npmjs.org.uk' ,
44- 'https://registry.npmjs.org.uk/foo/bar'
45- ] ) {
46- test ( c , ( ) => {
47- const actual = Contrib . FromNodePackageJson . Utils . defaultRegistryMatcher . test ( c )
48- assert . strictEqual ( actual , false )
49- } )
50- }
31+ suite ( 'unit: Contrib.FromNodePackageJson.Utils' , ( ) => {
32+ suite ( 'defaultRegistryMatcher' , ( ) => {
33+ test ( 'matches pure domain' , ( ) => {
34+ const actual = Contrib . FromNodePackageJson . Utils . defaultRegistryMatcher . test ( 'https://registry.npmjs.org' )
35+ assert . strictEqual ( actual , true )
36+ } )
37+ test ( 'matches with path' , ( ) => {
38+ const actual = Contrib . FromNodePackageJson . Utils . defaultRegistryMatcher . test ( 'https://registry.npmjs.org/foo/bar' )
39+ assert . strictEqual ( actual , true )
40+ } )
41+ suite ( 'not match unexpected' , ( ) => {
42+ for ( const c of [
43+ 'https://my-own=registry.local' ,
44+ 'https://registry.npmjs.org.uk' ,
45+ 'https://registry.npmjs.org.uk/foo/bar'
46+ ] ) {
47+ test ( c , ( ) => {
48+ const actual = Contrib . FromNodePackageJson . Utils . defaultRegistryMatcher . test ( c )
49+ assert . strictEqual ( actual , false )
50+ } )
51+ }
52+ } )
5153 } )
52- } )
5354
54- suite ( 'unit: Contrib.FromNodePackageJson.Utils.parsePackageIntegrity' , ( ) => {
55- suite ( 'as expected' , ( ) => {
56- for ( const [ c , ...expected ] of [
57- [ 'sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==' ,
58- HashAlgorithm [ 'SHA-512' ] ,
59- 'cef8fae53905788b778ba6a3e5b22f243ce38d0406b38a3fb0da1ece0d45d6461aa7d36eda3714769c334522531cc3331b41fb6d9927e2b350a489a1bb1597d8'
60- ] ,
61- [ 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0=' ,
62- HashAlgorithm [ 'SHA-1' ] ,
63- '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
64- ] ,
65- [ 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' ,
66- HashAlgorithm [ 'SHA-256' ] ,
67- 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
68- ] ,
69- [ 'sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC' ,
70- HashAlgorithm [ 'SHA-384' ] ,
71- 'a2a56e01f5d129aa7b7dd81c098e6eca433af91f46a90f0afeec72f6bc7b1cd42519897590fcd0868d70c7827063cc02'
72- ] ,
73- ] ) {
74- test ( c , ( ) => {
75- const actual = Contrib . FromNodePackageJson . Utils . parsePackageIntegrity ( c )
76- assert . deepStrictEqual ( actual , expected )
77- } )
78- }
79- } )
80- suite ( 'fails' , ( ) => {
81- for ( const c of [
82- 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0' , // missing character
83- 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0==' , // additional character
84- 'sha512-Kq5sNclPz7QV2+lfQIuc6R7oRu0=' , // alg and hash dont match
85- ] ) {
86- test ( c , ( ) => {
87- assert . throws ( ( ) => {
88- Contrib . FromNodePackageJson . Utils . parsePackageIntegrity ( c )
55+ suite ( 'unit: parsePackageIntegrity' , ( ) => {
56+ suite ( 'as expected' , ( ) => {
57+ for ( const [ c , ...expected ] of [
58+ [ 'sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==' ,
59+ HashAlgorithm [ 'SHA-512' ] ,
60+ 'cef8fae53905788b778ba6a3e5b22f243ce38d0406b38a3fb0da1ece0d45d6461aa7d36eda3714769c334522531cc3331b41fb6d9927e2b350a489a1bb1597d8'
61+ ] ,
62+ [ 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0=' ,
63+ HashAlgorithm [ 'SHA-1' ] ,
64+ '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed'
65+ ] ,
66+ [ 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' ,
67+ HashAlgorithm [ 'SHA-256' ] ,
68+ 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
69+ ] ,
70+ [ 'sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC' ,
71+ HashAlgorithm [ 'SHA-384' ] ,
72+ 'a2a56e01f5d129aa7b7dd81c098e6eca433af91f46a90f0afeec72f6bc7b1cd42519897590fcd0868d70c7827063cc02'
73+ ] ,
74+ ] ) {
75+ test ( c , ( ) => {
76+ const actual = Contrib . FromNodePackageJson . Utils . parsePackageIntegrity ( c )
77+ assert . deepStrictEqual ( actual , expected )
78+ } )
79+ }
80+ } )
81+ suite ( 'fails' , ( ) => {
82+ for ( const c of [
83+ 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0' , // missing character
84+ 'sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0==' , // additional character
85+ 'sha512-Kq5sNclPz7QV2+lfQIuc6R7oRu0=' , // alg and hash dont match
86+ ] ) {
87+ test ( c , ( ) => {
88+ assert . throws ( ( ) => {
89+ Contrib . FromNodePackageJson . Utils . parsePackageIntegrity ( c )
90+ } )
8991 } )
90- } )
91- }
92+ }
93+ } )
9294 } )
9395} )
0 commit comments