* feat: add npm downloads (by author) badge * Update services/npm-stat/npm-stat-downloads.service.js Co-authored-by: chris48s <chris48s@users.noreply.github.com> * test: add test cases for NpmStatDownloads helper getTotalDownloads * refactor: using dayjs to get from && until date string * feat: remove support of dt --------- Co-authored-by: chris48s <chris48s@users.noreply.github.com>
36 lines
925 B
JavaScript
36 lines
925 B
JavaScript
import { isMetricOverTimePeriod } from '../test-validators.js'
|
|
import { createServiceTester } from '../tester.js'
|
|
export const t = await createServiceTester()
|
|
|
|
t.create('weekly downloads of npm author dukeluo')
|
|
.get('/dw/dukeluo.json')
|
|
.expectBadge({
|
|
label: 'downloads',
|
|
message: isMetricOverTimePeriod,
|
|
color: 'brightgreen',
|
|
})
|
|
|
|
t.create('monthly downloads of npm author dukeluo')
|
|
.get('/dm/dukeluo.json')
|
|
.expectBadge({
|
|
label: 'downloads',
|
|
message: isMetricOverTimePeriod,
|
|
color: 'brightgreen',
|
|
})
|
|
|
|
t.create('yearly downloads of npm author dukeluo')
|
|
.get('/dy/dukeluo.json')
|
|
.expectBadge({
|
|
label: 'downloads',
|
|
message: isMetricOverTimePeriod,
|
|
color: 'brightgreen',
|
|
})
|
|
|
|
t.create('downloads of unknown npm package author')
|
|
.get('/dy/npm-api-does-not-have-this-package-author.json')
|
|
.expectBadge({
|
|
label: 'downloads',
|
|
message: '0/year',
|
|
color: 'red',
|
|
})
|