Files
shields/services/hexpm/hexpm.tester.js
dependabot[bot] b9d96755ec chore(deps-dev): bump prettier from 2.8.8 to 3.0.0 (#9357)
* chore(deps-dev): bump prettier from 2.8.8 to 3.0.0

Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* reformat all the things (prettier 3)

* update tests to await calls to prettier.format()

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: chris48s <git@chris-shaw.dev>
2023-07-10 09:27:51 +00:00

111 lines
2.9 KiB
JavaScript

import Joi from 'joi'
import { ServiceTester } from '../tester.js'
import {
isMetric,
isMetricOverTimePeriod,
isVPlusDottedVersionNClausesWithOptionalSuffix,
} from '../test-validators.js'
export const t = new ServiceTester({ id: 'hexpm', title: 'Hex.pm' })
t.create('downloads per week')
.get('/dw/cowboy.json')
.expectBadge({ label: 'downloads', message: isMetricOverTimePeriod })
t.create('downloads per day')
.get('/dd/cowboy.json')
.expectBadge({ label: 'downloads', message: isMetricOverTimePeriod })
t.create('downloads (zero for period)')
.get('/dd/cowboy.json')
.intercept(nock =>
nock('https://hex.pm/')
.get('/api/packages/cowboy')
.reply(200, {
downloads: { all: 100 }, // there is no 'day' key here
latest_stable_version: '1.0',
latest_version: '1.0',
meta: { licenses: ['MIT'] },
}),
)
.expectBadge({ label: 'downloads', message: '0/day' })
t.create('downloads in total')
.get('/dt/cowboy.json')
.expectBadge({ label: 'downloads', message: isMetric })
t.create('downloads (not found)')
.get('/dt/this-package-does-not-exist.json')
.expectBadge({ label: 'downloads', message: 'not found' })
t.create('version').get('/v/cowboy.json').expectBadge({
label: 'hex',
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
})
t.create('version (no stable version)')
.get('/v/prima_opentelemetry_ex.json')
.intercept(nock =>
nock('https://hex.pm/')
.get('/api/packages/prima_opentelemetry_ex')
.reply(200, {
downloads: { all: 100 },
latest_version: '1.0.0-rc.3',
meta: { licenses: ['MIT'] },
}),
)
.expectBadge({
label: 'hex',
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
})
t.create('version (not found)')
.get('/v/this-package-does-not-exist.json')
.expectBadge({ label: 'hex', message: 'not found' })
t.create('license').get('/l/cowboy.json').expectBadge({
label: 'license',
message: Joi.string().required(),
color: 'blue',
})
t.create('license (multiple licenses)')
.get('/l/cowboy.json')
.intercept(nock =>
nock('https://hex.pm/')
.get('/api/packages/cowboy')
.reply(200, {
downloads: { all: 100 },
latest_stable_version: '1.0',
latest_version: '1.0',
meta: { licenses: ['GPLv2', 'MIT'] },
}),
)
.expectBadge({
label: 'licenses',
message: 'GPLv2, MIT',
color: 'blue',
})
t.create('license (no license)')
.get('/l/cowboy.json')
.intercept(nock =>
nock('https://hex.pm/')
.get('/api/packages/cowboy')
.reply(200, {
downloads: { all: 100 },
latest_stable_version: '1.0',
latest_version: '1.0',
meta: { licenses: [] },
}),
)
.expectBadge({
label: 'license',
message: 'Unknown',
color: 'lightgrey',
})
t.create('license (not found)')
.get('/l/this-package-does-not-exist.json')
.expectBadge({ label: 'license', message: 'not found' })