* use defaultLabel in renderVersionBadge without tag As we refactor the codebase to use renderVersionBadge. some badges need to show default label regardless of tag existance. This is usefull for cases where the label is dynamic. This change requires fixing test for npm, not sure how it worked before. * Refactor AurVersion to use renderVersionBadge part of #2026 * Refactor CondaVersion to use renderVersionBadge part of #2026 * Refactor WordpressRequiresVersion to use renderVersionBadge * add postfix option to renderVersionBadge * add missing tests for renderVersionBadge add defaultLabel without tag test add postfix test add test for all options together * Refactor WordpressPluginTestedVersion to use renderVersionBadge * add prefix override to renderVersionBadge adds tests for all options with prefix as well used for #2026 but also usefull for usage letting people override v prefix for versions all over the project once #2026 is done as requested for example in #10574 * Refactor RequiresPHPVersionForType to use renderVersionBadge
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
import { expect } from 'chai'
|
|
import nock from 'nock'
|
|
import { cleanUpNockAfterEach, defaultContext } from '../test-helpers.js'
|
|
// use NPM Version as an example implementation of NpmBase for this test
|
|
import NpmVersion from './npm-version.service.js'
|
|
|
|
describe('npm', function () {
|
|
describe('auth', function () {
|
|
it('sends the auth information as configured', async function () {
|
|
cleanUpNockAfterEach()
|
|
|
|
const token = 'abc123'
|
|
|
|
const scope = nock('https://registry.npmjs.org', {
|
|
reqheaders: { Accept: '*/*', Authorization: `Bearer ${token}` },
|
|
})
|
|
.get('/-/package/npm/dist-tags')
|
|
.reply(200, { latest: '0.1.0' })
|
|
|
|
const config = {
|
|
public: {
|
|
services: {
|
|
npm: {
|
|
authorizedOrigins: ['https://registry.npmjs.org'],
|
|
},
|
|
},
|
|
},
|
|
private: {
|
|
npm_token: token,
|
|
},
|
|
}
|
|
|
|
expect(
|
|
await NpmVersion.invoke(defaultContext, config, { packageName: 'npm' }),
|
|
).to.deep.equal({
|
|
color: 'orange',
|
|
label: 'npm',
|
|
message: 'v0.1.0',
|
|
})
|
|
|
|
scope.done()
|
|
})
|
|
})
|
|
})
|