Files
shields/services/factorio-mod-portal/factorio-mod-portal.tester.js
kuanoni 755af712ae [factorio-mod-portal] services (#8625)
* add latest version service

* add game version service

* update game version service, includes version range

* add game version and latest version service tests

* add last updated service & tests

* add downloads service

* url changes

* add 'range' query to factorio versions

* renamed function to transform

* validate downloads via nonNegativeInteger

https://github.com/badges/shields/pull/8625#discussion_r1021557183

* change version route to /v

https://github.com/badges/shields/pull/8625#discussion_r1021558937

* factorio-version category to platform-support

https://github.com/badges/shields/pull/8625#discussion_r1021557896

* change downloads route to /dt

https://github.com/badges/shields/pull/8625#discussion_r1021559841

* version validator to isVPlusDottedVersionNClauses

https://github.com/badges/shields/pull/8625#discussion_r1021563736

* removed range query param from factorio-version

https://github.com/badges/shields/pull/8625#discussion_r1021568758
2022-11-16 20:36:19 +00:00

48 lines
1.5 KiB
JavaScript

import {
isVPlusDottedVersionNClauses,
isFormattedDate,
isMetric,
} from '../test-validators.js'
import { ServiceTester } from '../tester.js'
export const t = new ServiceTester({
id: 'factorio-mod-portal',
title: 'Factorio Mod Portal',
})
t.create('Latest Version (rso-mod, valid)').get('/v/rso-mod.json').expectBadge({
label: 'latest version',
message: isVPlusDottedVersionNClauses,
})
t.create('Latest Version (mod not found)')
.get('/v/mod-that-doesnt-exist.json')
.expectBadge({ label: 'latest version', message: 'mod not found' })
t.create('Factorio Version (rso-mod, valid)')
.get('/factorio-version/rso-mod.json')
.expectBadge({
label: 'factorio version',
message: isVPlusDottedVersionNClauses,
})
t.create('Factorio Version (mod not found)')
.get('/factorio-version/mod-that-doesnt-exist.json')
.expectBadge({ label: 'factorio version', message: 'mod not found' })
t.create('Last Updated (rso-mod, valid)')
.get('/last-updated/rso-mod.json')
.expectBadge({ label: 'last updated', message: isFormattedDate })
t.create('Last Updated (mod not found)')
.get('/last-updated/mod-that-doesnt-exist.json')
.expectBadge({ label: 'last updated', message: 'mod not found' })
t.create('Downloads (rso-mod, valid)')
.get('/dt/rso-mod.json')
.expectBadge({ label: 'downloads', message: isMetric })
t.create('Downloads (mod not found)')
.get('/dt/mod-that-doesnt-exist.json')
.expectBadge({ label: 'downloads', message: 'mod not found' })