This repository was archived by the owner on Jul 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.js
More file actions
75 lines (57 loc) · 1.69 KB
/
tests.js
File metadata and controls
75 lines (57 loc) · 1.69 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* eslint-env mocha */
const { expect } = require('chai')
/**
* [testSuite description]
*
* @param {any} T The exported value from the module under test.
*
* @return {undefined}
*/
function testSuite (T) {
it('must export a function', () => {
const expected = 'function'
const actual = typeof T
expect(actual).to.equal(expected)
})
it('must return an integer', () => {
const expected = true
const actual = Number.isInteger(T(new Date()))
expect(actual).to.equal(expected)
})
it('must return the correct value for January 2021', () => {
const expected = 6
const actual = T(new Date(2021, 0, 1))
expect(actual).to.equal(expected)
})
it('must return the correct value for February 2021', () => {
const expected = 5
const actual = T(new Date(2021, 1, 1))
expect(actual).to.equal(expected)
})
it('must return the correct value for November 2020', () => {
const expected = 5
const actual = T(new Date(2020, 10, 1))
expect(actual).to.equal(expected)
})
it('must return the correct value for October 2020', () => {
const expected = 5
const actual = T(new Date(2020, 9, 1))
expect(actual).to.equal(expected)
})
it('must return the correct value for September 2020', () => {
const expected = 5
const actual = T(new Date(2020, 8, 1))
expect(actual).to.equal(expected)
})
}
describe('the "number of weeks" module', () => {
context('implemented with vanilla JS', () => {
testSuite(require('./vanilla.js'))
})
context('implemented with luxon', () => {
testSuite(require('./luxon.js'))
})
context('implemented as a 1-liner', () => {
testSuite(require('./one-liner.js'))
})
})