-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLICENSE.test.js
More file actions
30 lines (23 loc) · 842 Bytes
/
LICENSE.test.js
File metadata and controls
30 lines (23 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { AssertionError } from 'node:assert'
import { fileURLToPath } from 'url'
import path from 'path'
import { readFile } from 'fs/promises'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const yearRegExp = /2013\u2013(?<year>\d{4})/u
describe(`LICENSE`, function() {
it(`has the correct year`, async function() {
const licensePath = path.join(__dirname, `./LICENSE.md`)
const text = await readFile(licensePath, `utf8`)
const { year } = yearRegExp.exec(text).groups
const currentYear = new Date().getFullYear().toString()
if (year !== currentYear) {
throw new AssertionError({
actual: currentYear,
expected: year,
message: `Incorrect year in license.`,
operator: `=`,
})
}
})
})