Files
shields/services/maintenance/maintenance.tester.js
T
Caleb CartwrightandPaul Melnikow 263e1be06d tests(Maintenance): refactor and test (#3305)
One of the tests for the Maintenance service that was added when the service was refactored is failing 
`AssertionError: message mismatch: expected 'no! (as of 2018)' to equal 'stale (as of 2019)'`

I believe the test was added in an attempt to cover the one of the code paths, but that original test would only pass a couple months out of the year. 

Testing those paths with the original implementation would have required a lot of stubbing clocks/timers, so instead I refactored the code a bit. I removed the flaky live/service test, and added some unit tests instead (which made more sense to me since this service badge doesn't hit a live endpoint)
2019-04-15 12:47:06 -04:00

22 lines
719 B
JavaScript

'use strict'
const t = (module.exports = require('../tester').createServiceTester())
const currentYear = new Date().getUTCFullYear()
t.create('yes last maintained 2016 (no)')
.get('/yes/2016.json')
.expectBadge({ label: 'maintained', message: 'no! (as of 2016)' })
t.create('no longer maintained 2017 (no)')
.get('/no/2017.json')
.expectBadge({ label: 'maintained', message: 'no! (as of 2017)' })
t.create('yes this year (yes)')
.get(`/yes/${currentYear}.json`)
.expectBadge({ label: 'maintained', message: 'yes' })
t.create(`until end of ${currentYear} (yes)`)
.get(`/until end of ${currentYear}/${currentYear}.json`)
.expectBadge({ label: 'maintained', message: `until end of ${currentYear}` })