test: added more date tests and added download tests; workflow: mapped @/ path in jest config

This commit is contained in:
Roberto Tonino
2021-06-02 17:28:45 +02:00
parent bda628b30b
commit 21b7629bdc
4 changed files with 28 additions and 6 deletions

View File

@@ -2,8 +2,15 @@ import { checkNewRelease } from '../../../src/utils/dates.js'
describe('date utils', () => {
describe('checkNewRelease', () => {
it("returns true with today's date", () => {
it("returns a positive result checking today's date", () => {
expect(checkNewRelease(new Date())).toBe(true)
})
it("returns a negative result checking a week ago's date", () => {
const dateToCheck = new Date()
dateToCheck.setDate(dateToCheck.getDate() - 7)
expect(checkNewRelease(dateToCheck)).toBe(false)
})
})
})

View File

@@ -0,0 +1,12 @@
import { aggregateDownloadLinks } from '../../../src/utils/downloads'
describe('download utils', () => {
describe('aggregateDownloadLinks', () => {
it('merges links into a single string', () => {
const release = { link: 'abcde' }
const aggregated = aggregateDownloadLinks([release, release])
expect(aggregated).toBe('abcde;abcde')
})
})
})