* 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
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
import { isIecFileSize } from '../test-validators.js'
|
|
import { createServiceTester } from '../tester.js'
|
|
export const t = await createServiceTester()
|
|
|
|
t.create('File size')
|
|
.get('/webcaetano/craft/build/phaser-craft.min.js.json')
|
|
.expectBadge({ label: 'size', message: isIecFileSize })
|
|
|
|
t.create('File size 404')
|
|
.get('/webcaetano/craft/build/does-not-exist.min.js.json')
|
|
.expectBadge({ label: 'size', message: 'repo or file not found' })
|
|
|
|
t.create('File size for nonexisting branch')
|
|
.get('/webcaetano/craft/build/phaser-craft.min.js.json?branch=notARealBranch')
|
|
.expectBadge({ label: 'size', message: 'repo, branch or file not found' })
|
|
|
|
t.create('File size for "not a regular file"')
|
|
.get('/webcaetano/craft/build.json')
|
|
.expectBadge({ label: 'size', message: 'not a regular file' })
|
|
|
|
t.create('File size for a specified branch')
|
|
.get('/webcaetano/craft/build/craft.min.js.json?branch=version-2')
|
|
.expectBadge({ label: 'size', message: isIecFileSize })
|
|
|
|
t.create('File size for a specified tag')
|
|
.get('/webcaetano/craft/build/phaser-craft.min.js.json?branch=2.1.2')
|
|
.expectBadge({ label: 'size', message: isIecFileSize })
|
|
|
|
t.create('File size for a specified commit')
|
|
.get('/webcaetano/craft/build/phaser-craft.min.js.json?branch=b848dbb')
|
|
.expectBadge({ label: 'size', message: isIecFileSize })
|