npq 3.2.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/marshalls.provenance.test.js +1 -1
- package/__tests__/packageRepoUtils.test.js +24 -0
- package/data/top-packages.json +50000 -0
- package/lib/helpers/packageRepoUtils.js +22 -0
- package/lib/marshalls/author.marshall.js +10 -5
- package/lib/marshalls/provenance.marshall.js +8 -3
- package/lib/marshalls/signatures.marshall.js +3 -0
- package/package.json +2 -1
- package/scripts/build.js +25 -0
|
@@ -196,7 +196,7 @@ describe('Provenance test suites', () => {
|
|
|
196
196
|
// We assert that the validate method didn't throw an error,
|
|
197
197
|
// because the keys match the signature
|
|
198
198
|
await expect(testMarshall.validate(pkg)).rejects.toThrow(
|
|
199
|
-
'the package was published without any attestations.
|
|
199
|
+
'the package was published without any attestations.'
|
|
200
200
|
)
|
|
201
201
|
|
|
202
202
|
// Assert that the fetch method is called with the correct URL
|
|
@@ -136,3 +136,27 @@ test('repo utils parses package version', async () => {
|
|
|
136
136
|
)
|
|
137
137
|
expect(result).toBeTruthy()
|
|
138
138
|
})
|
|
139
|
+
|
|
140
|
+
test('repo utils returns valid semver for different cases of version asked', async () => {
|
|
141
|
+
const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
|
|
142
|
+
global.fetch = jest.fn().mockImplementation(() =>
|
|
143
|
+
Promise.resolve({
|
|
144
|
+
json: () => require('./mocks/registryPackageOk.mock.json')
|
|
145
|
+
})
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
const packageRepoUtils = new PackageRepoUtils()
|
|
149
|
+
const packageName = 'testPackage'
|
|
150
|
+
|
|
151
|
+
let result
|
|
152
|
+
|
|
153
|
+
result = await packageRepoUtils.getSemVer(packageName, 'latest')
|
|
154
|
+
expect(result).toEqual('3.1.0')
|
|
155
|
+
|
|
156
|
+
result = await packageRepoUtils.getSemVer(packageName, '3.1.0')
|
|
157
|
+
expect(result).toEqual('3.1.0')
|
|
158
|
+
|
|
159
|
+
await expect(packageRepoUtils.getSemVer(packageName, 'next')).rejects.toThrow(
|
|
160
|
+
'could not find dist-tag next for package testPackage'
|
|
161
|
+
)
|
|
162
|
+
})
|