Skip to content

Commit 03e617d

Browse files
committed
dings
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 098d303 commit 03e617d

3 files changed

Lines changed: 63 additions & 61 deletions

File tree

tests/unit/Contrib.Bom.Utils.randomSerialNumber.spec.js renamed to tests/unit/Contrib.Bom.Utils.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const {
2525
Contrib,
2626
} = require('../../')
2727

28-
suite('unit: Contrib.Bom.Utils.randomSerialNumber', () => {
28+
suite('unit: Contrib.Bom.Utils', () => {
2929
suite('randomSerialNumber()', () => {
3030
test('has correct format according to XSD', () => {
3131
const value = Contrib.Bom.Utils.randomSerialNumber()

tests/unit/Contrib.FromNodePackageJson.Factories.PackageUrlFactory.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ suite('unit: Contrib.FromNodePackageJson.Factories.PackageUrlFactory', () => {
4646
)
4747
])
4848
})
49-
const purlFac = new PackageUrlFactory('npm')
49+
const purlFac = new Contrib.FromNodePackageJson.Factories.PackageUrlFactory('npm')
5050
const actual = purlFac.makeFromComponent(component)
5151
assert.deepEqual(actual, {
5252
type: 'npm',
@@ -68,7 +68,7 @@ suite('unit: Contrib.FromNodePackageJson.Factories.PackageUrlFactory', () => {
6868
)
6969
])
7070
})
71-
const purlFac = new PackageUrlFactory('npm')
71+
const purlFac = new Contrib.FromNodePackageJson.Factories.PackageUrlFactory('npm')
7272
const actual = purlFac.makeFromComponent(component)
7373
assert.deepEqual(actual,
7474
{

tests/unit/Contrib.FromNodePackageJson.Utils.spec.js

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)