Files
shields/services/steam/steam-workshop.tester.js
chris48s 151c70dd17 Add ability to format bytes as metric or IEC; affects [bundlejs bundlephobia ChromeWebStoreSize CratesSize DockerSize GithubRepoSize GithubCodeSize GithubSize NpmUnpackedSize SpigetDownloadSize steam VisualStudioAppCenterReleasesSize whatpulse] (#10547)
* add renderSizeBadge helper, use it everywhere

- switch from pretty-bytes to byte-size
- add renderSizeBadge() helper function
- match upstream conventions for metric/IEC units
- add new test helpers and use them in service tests

* unrelated: fix npm unpacked size query param schema

not strictly related to this PR
but I noticed it was broken

* chromewebstore: reformat size string, test against isIecFileSize
2024-12-01 19:53:26 +00:00

76 lines
2.3 KiB
JavaScript

import { ServiceTester } from '../tester.js'
import {
isMetric,
isMetricFileSize,
isFormattedDate,
} from '../test-validators.js'
export const t = new ServiceTester({
id: 'steam',
title: 'Steam Workshop Tests',
})
t.create('Collection Files')
.get('/collection-files/180077636.json')
.expectBadge({ label: 'files', message: isMetric })
t.create('File Size')
.get('/size/1523924535.json')
.expectBadge({ label: 'size', message: isMetricFileSize })
t.create('Release Date')
.get('/release-date/1523924535.json')
.expectBadge({ label: 'release date', message: isFormattedDate })
t.create('Update Date')
.get('/update-date/1523924535.json')
.expectBadge({ label: 'update date', message: isFormattedDate })
t.create('Subscriptions')
.get('/subscriptions/1523924535.json')
.expectBadge({ label: 'subscriptions', message: isMetric })
t.create('Favorites')
.get('/favorites/1523924535.json')
.expectBadge({ label: 'favorites', message: isMetric })
t.create('Downloads')
.get('/downloads/1523924535.json')
.expectBadge({ label: 'downloads', message: isMetric })
t.create('Views')
.get('/views/1523924535.json')
.expectBadge({ label: 'views', message: isMetric })
t.create('Collection Files | Collection Not Found')
.get('/collection-files/1.json')
.expectBadge({ label: 'files', message: 'collection not found' })
t.create('File Size | File Not Found')
.get('/size/1.json')
.expectBadge({ label: 'size', message: 'file not found' })
t.create('Release Date | File Not Found')
.get('/release-date/1.json')
.expectBadge({ label: 'release date', message: 'file not found' })
t.create('Update Date | File Not Found')
.get('/update-date/1.json')
.expectBadge({ label: 'update date', message: 'file not found' })
t.create('Subscriptions | File Not Found')
.get('/subscriptions/1.json')
.expectBadge({ label: 'subscriptions', message: 'file not found' })
t.create('Favorites | File Not Found')
.get('/favorites/1.json')
.expectBadge({ label: 'favorites', message: 'file not found' })
t.create('Downloads | File Not Found')
.get('/downloads/1.json')
.expectBadge({ label: 'downloads', message: 'file not found' })
t.create('Views | File Not Found')
.get('/views/1.json')
.expectBadge({ label: 'views', message: 'file not found' })