Skip to content

Commit 164af45

Browse files
use old tape test format again
1 parent cf73a6b commit 164af45

63 files changed

Lines changed: 5357 additions & 1848 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 3595 additions & 169 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
"pack": "node ./zonefile/pack.js",
2626
"version": "node ./scripts/version.js",
2727
"watch": "node --watch ./scratch.js",
28-
"test": "node --test --test-reporter=./scripts/testReporter.js ./test/*.test.js | tap-dancer --color always",
29-
"testb": "echo '== production build test 🚀 ==' && TESTENV=prod node --test --test-reporter=./scripts/testReporter.js ./test/*.test.js | tap-dancer --color always",
30-
"test:types": "node --import tsx --test --test-reporter=./scripts/testReporter.js ./test/types/index.ts | tap-dancer --color always",
28+
"test": "tape ./test/**/*.test.js | tap-dancer --color always",
29+
"testb": "TESTENV=prod tape ./test/**/*.test.js | tap-dancer --color always",
30+
"test:types": "tsx ./test/types/index.ts | tap-dancer --color always",
3131
"coverage": "nyc -r lcov -n 'src/**/*' -n 'plugins/**/*' npm run coverage:tests",
3232
"coverage:tests": "npm run test",
3333
"codecov": "npm run coverage && codecov -t 411de6c7-82d2-41e9-a1cc-9096cdab6c72",
@@ -57,10 +57,12 @@
5757
"@rollup/plugin-node-resolve": "^16.0.3",
5858
"@rollup/plugin-terser": "^1.0.0",
5959
"@types/node": "25.9.1",
60+
"@types/tape": "5.8.1",
6061
"eslint-plugin-regexp": "3.1.0",
6162
"rollup": "4.60.4",
6263
"shelljs": "0.10.0",
6364
"tap-dancer": "0.3.4",
65+
"tape": "5.9.0",
6466
"timekeeper": "2.3.1",
6567
"tslib": "2.8.1",
6668
"tsx": "4.22.3",

scripts/testReporter.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/add.test.js

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
import { test } from 'node:test'
2-
import assert from './lib/assert.js'
1+
import test from 'tape'
32
import spacetime from './lib/index.js'
43

5-
test('add', () => {
4+
test('add', (t) => {
65
let s = spacetime('January 1, 2017 1:20:05', 'Canada/Eastern')
76
//initial state
8-
assert.equal(s.date(), 1, '.date()')
9-
assert.equal(s.monthName(), 'january', '.month()')
10-
assert.equal(s.year(), 2017, '.year()')
11-
assert.equal(s.hour(), 1, '.hour()')
12-
assert.equal(s.minute(), 20, '.minute()')
13-
assert.equal(s.dayName(), 'sunday', '.day()')
7+
t.equal(s.date(), 1, '.date()')
8+
t.equal(s.monthName(), 'january', '.month()')
9+
t.equal(s.year(), 2017, '.year()')
10+
t.equal(s.hour(), 1, '.hour()')
11+
t.equal(s.minute(), 20, '.minute()')
12+
t.equal(s.dayName(), 'sunday', '.day()')
1413

1514
s = s.add(1, 'hour')
16-
assert.equal(s.hour(), 2, 'movehour-.hour()')
17-
assert.equal(s.minute(), 20, 'movehour-.minute()')
18-
assert.equal(s.date(), 1, 'movehour-.date()')
19-
assert.equal(s.month(), 0, 'movehour-.month()')
20-
assert.equal(s.year(), 2017, 'movehour-.year()')
15+
t.equal(s.hour(), 2, 'movehour-.hour()')
16+
t.equal(s.minute(), 20, 'movehour-.minute()')
17+
t.equal(s.date(), 1, 'movehour-.date()')
18+
t.equal(s.month(), 0, 'movehour-.month()')
19+
t.equal(s.year(), 2017, 'movehour-.year()')
2120

2221
s = s.add(1, 'month')
23-
assert.equal(s.date(), 1, 'movemonth.date()')
24-
assert.equal(s.monthName(), 'february', 'movemonth.month()')
25-
assert.equal(s.year(), 2017, 'movemonth.year()')
22+
t.equal(s.date(), 1, 'movemonth.date()')
23+
t.equal(s.monthName(), 'february', 'movemonth.month()')
24+
t.equal(s.year(), 2017, 'movemonth.year()')
2625

2726
s = s.add(2, 'days')
28-
assert.equal(s.date(), 3, 'moveday-.date()')
29-
assert.equal(s.monthName(), 'february', 'moveday-.month()')
30-
assert.equal(s.year(), 2017, 'moveday-.year()')
31-
assert.equal(s.dayName(), 'friday', 'moveday-.day()')
27+
t.equal(s.date(), 3, 'moveday-.date()')
28+
t.equal(s.monthName(), 'february', 'moveday-.month()')
29+
t.equal(s.year(), 2017, 'moveday-.year()')
30+
t.equal(s.dayName(), 'friday', 'moveday-.day()')
3231

3332
s = s.add(1, 'week')
34-
assert.equal(s.date(), 10, 'moveweek-.date()')
35-
assert.equal(s.monthName(), 'february', 'moveweek-.month()')
36-
assert.equal(s.year(), 2017, 'moveweek-.year()')
37-
assert.equal(s.dayName(), 'friday', 'moveweek-.day()')
33+
t.equal(s.date(), 10, 'moveweek-.date()')
34+
t.equal(s.monthName(), 'february', 'moveweek-.month()')
35+
t.equal(s.year(), 2017, 'moveweek-.year()')
36+
t.equal(s.dayName(), 'friday', 'moveweek-.day()')
3837

3938
s = s.add(1, 'year')
40-
assert.equal(s.date(), 10, 'moveyear.date()')
41-
assert.equal(s.monthName(), 'february', 'moveyear.month()')
42-
assert.equal(s.year(), 2018, 'moveyear.year()')
39+
t.equal(s.date(), 10, 'moveyear.date()')
40+
t.equal(s.monthName(), 'february', 'moveyear.month()')
41+
t.equal(s.year(), 2018, 'moveyear.year()')
4342

4443
s = spacetime('January 1, 2017 1:20:05', 'Canada/Eastern')
4544
// s.add(1, 'quarter');
46-
// assert.equal(s.date(), 1, 'movequarter.date()');
47-
// assert.equal(s.monthName(), 'april', 'movequarter.date()');
45+
// t.equal(s.date(), 1, 'movequarter.date()');
46+
// t.equal(s.monthName(), 'april', 'movequarter.date()');
4847
s = s.add(2, 'years')
49-
assert.equal(s.date(), 1, 'moveyear-.date()')
50-
// assert.equal(s.monthName(), 'april', 'moveyear.month()');
51-
assert.equal(s.year(), 2019, 'moveyear.year()')
48+
t.equal(s.date(), 1, 'moveyear-.date()')
49+
// t.equal(s.monthName(), 'april', 'moveyear.month()');
50+
t.equal(s.year(), 2019, 'moveyear.year()')
5251

5352
s = s.add(1, 'decade')
54-
assert.equal(s.year(), 2029, 'move-decade.year()')
53+
t.equal(s.year(), 2029, 'move-decade.year()')
5554

5655
s = s.add(1, 'quarterHour')
57-
assert.equal(s.minute(), 35, 'movequarterHour')
56+
t.equal(s.minute(), 35, 'movequarterHour')
5857

5958
s = s.add(1, 'quarterHour')
60-
assert.equal(s.minute(), 50, 'movequarterHour#2')
59+
t.equal(s.minute(), 50, 'movequarterHour#2')
6160

6261
s = s.time('3:31pm')
6362
s = s.add(4, 'quarter-hour')
64-
assert.equal(s.time(), '4:31pm', 'add 2 quarter-hours')
63+
t.equal(s.time(), '4:31pm', 'add 2 quarter-hours')
6564

65+
t.end()
6666
})
6767

68-
test('adding 0 changes nothing', () => {
68+
test('adding 0 changes nothing', (t) => {
6969
let s = spacetime.now()
7070
const a = s.clone()
7171
s = s.add(0, 'month')
@@ -76,79 +76,86 @@ test('adding 0 changes nothing', () => {
7676
s = s.add(0, 'minute')
7777
s = s.minus(0, 'minute')
7878
s = s.minus(0, 'days')
79-
assert.equal(s.epoch, a.epoch, 'time-didnt change')
79+
t.equal(s.epoch, a.epoch, 'time-didnt change')
8080

8181
s = spacetime('dec 25 2018')
8282
const before = s.format('nice-year')
8383
s = s.add(0, 'years')
84-
assert.equal(s.format('nice-year'), before, 'year didnt change')
84+
t.equal(s.format('nice-year'), before, 'year didnt change')
85+
t.end()
8586
})
8687

87-
test('hour-tricky', () => {
88+
test('hour-tricky', (t) => {
8889
let s = spacetime('January 1, 2017 13:20:00', 'Canada/Pacific')
89-
assert.equal(s.hour(), 13, 'init.hour()')
90-
assert.equal(s.minute(), 20, 'init.minute()')
90+
t.equal(s.hour(), 13, 'init.hour()')
91+
t.equal(s.minute(), 20, 'init.minute()')
9192

9293
s = s.add(1, 'hour')
93-
assert.equal(s.hour(), 14, '.hour()')
94-
assert.equal(s.minute(), 20, '.minute()')
94+
t.equal(s.hour(), 14, '.hour()')
95+
t.equal(s.minute(), 20, '.minute()')
96+
t.end()
9597
})
9698

97-
test('day-tricky', () => {
99+
test('day-tricky', (t) => {
98100
let d = spacetime('2019-11-04T00:00:00.000', 'Canada/Eastern')
99101
d = d.add(1, 'week')
100-
assert.equal(d.format('nice-day'), 'Mon Nov 11th', 'add week over dst-change')
102+
t.equal(d.format('nice-day'), 'Mon Nov 11th', 'add week over dst-change')
101103

102104
//same thing, but days
103105
d = spacetime('2019-11-04T00:00:00.000', 'Canada/Eastern')
104106
d = d.add(7, 'days')
105-
assert.equal(d.format('nice-day'), 'Mon Nov 11th', 'add days over dst-change')
107+
t.equal(d.format('nice-day'), 'Mon Nov 11th', 'add days over dst-change')
106108

107109
d = spacetime('2021-10-31T00:00:00.000', 'Europe/London')
108110
d = d.add(1, 'day')
109-
assert.equal(d.format('iso-utc'), '2021-11-01T00:00:00.000Z', 'add 1 day over dst-change')
111+
t.equal(d.format('iso-utc'), '2021-11-01T00:00:00.000Z', 'add 1 day over dst-change')
110112

111113
// add day over month-change
112114
let s = spacetime('Oct 31 2020', 'Canada/Eastern')
113115
s = s.add(2, 'day')
114-
assert.equal(s.format('nice'), 'Nov 2nd, 12:00am', 'add day over month-change')
116+
t.equal(s.format('nice'), 'Nov 2nd, 12:00am', 'add day over month-change')
115117
// add day over year-change
116118
s = spacetime('Dec 31 2020', 'Canada/Eastern')
117119
s = s.add(2, 'day')
118-
assert.equal(s.format('nice'), 'Jan 2nd, 12:00am', 'add day over year-change')
120+
t.equal(s.format('nice'), 'Jan 2nd, 12:00am', 'add day over year-change')
119121

122+
t.end()
120123
})
121124

122-
test('new-years-eve', () => {
125+
test('new-years-eve', (t) => {
123126
let year = 2022
124127
let nye = spacetime(`2022-01-01T00:00:00.000Z`)
125128
for (let i = 0; i < 20; i += 1) {
126129
nye = nye.minus(1, 'year')
127130
year -= 1
128-
assert.equal(nye.format(), `${year}-01-01`, `${year} exact millisecond`)
131+
t.equal(nye.format(), `${year}-01-01`, `${year} exact millisecond`)
129132
}
133+
t.end()
130134
})
131135

132-
test('add-weekend', () => {
136+
test('add-weekend', (t) => {
133137
let d = spacetime('2021-04-17')
134138
d = d.add(1, 'weekend')
135-
assert.equal(d.dayName(), 'saturday', 'is saturday')
136-
assert.equal(d.format('iso-short'), '2021-04-24', 'is ahead')
139+
t.equal(d.dayName(), 'saturday', 'is saturday')
140+
t.equal(d.format('iso-short'), '2021-04-24', 'is ahead')
141+
t.end()
137142
})
138143

139-
test('add-30-years', () => {
144+
test('add-30-years', (t) => {
140145
let d = spacetime('2000-01-01 00:00:00')
141146
d = d.add(30, 'year')
142-
assert.equal(d.format('iso-short'), '2030-01-01', 'plus 30 years')
147+
t.equal(d.format('iso-short'), '2030-01-01', 'plus 30 years')
148+
t.end()
143149
})
144150

145-
test('year-tricky', () => {
151+
test('year-tricky', (t) => {
146152
const s = spacetime(1451667600000, 'Canada/Eastern') //jan 1 2016 (leap year)
147-
assert.equal(s.year(), 2016, 'year1')
153+
t.equal(s.year(), 2016, 'year1')
148154

149155
const a = s.clone().add(1, 'year')
150-
assert.equal(a.year(), 2017, 'year-next')
156+
t.equal(a.year(), 2017, 'year-next')
151157

152158
const b = s.clone().subtract(1, 'year')
153-
assert.equal(b.year(), 2015, 'year-last')
159+
t.equal(b.year(), 2015, 'year-last')
160+
t.end()
154161
})

test/api.test.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import spacetime from './lib/index.js'
2-
import { test } from 'node:test'
3-
import assert from './lib/assert.js'
2+
import test from 'tape'
43
import api from '../api/index.js'
54

65
const instanceSections = ['main', 'getters', 'utils']
@@ -32,24 +31,26 @@ const staticUndocumented = new Set([
3231
])
3332

3433
// every documented instance method should actually exist as a function
35-
test('documented instance methods exist', () => {
34+
test('documented instance methods exist', (t) => {
3635
const s = spacetime('1998-03-28')
3736
instanceSections.forEach((section) => {
3837
Object.keys(api[section]).forEach((k) => {
39-
assert.equal(typeof s[k], 'function', `${section}.${k} exists`)
38+
t.equal(typeof s[k], 'function', `${section}.${k} exists`)
4039
})
4140
})
41+
t.end()
4242
})
4343

4444
// every documented static method should actually exist as a function
45-
test('documented static methods exist', () => {
45+
test('documented static methods exist', (t) => {
4646
Object.keys(api.statics).forEach((k) => {
47-
assert.equal(typeof spacetime[k], 'function', `statics.${k} exists`)
47+
t.equal(typeof spacetime[k], 'function', `statics.${k} exists`)
4848
})
49+
t.end()
4950
})
5051

5152
// every public instance method should be documented (catches docs falling behind the code)
52-
test('public instance methods are documented', () => {
53+
test('public instance methods are documented', (t) => {
5354
const s = spacetime('1998-03-28')
5455
const documented = new Set(instanceSections.flatMap((section) => Object.keys(api[section])))
5556
const proto = Object.getPrototypeOf(s)
@@ -59,19 +60,21 @@ test('public instance methods are documented', () => {
5960
if (undocumented.has(k)) {
6061
return
6162
}
62-
assert.ok(documented.has(k), `${k} is documented in api/index.js`)
63+
t.ok(documented.has(k), `${k} is documented in api/index.js`)
6364
})
65+
t.end()
6466
})
6567

6668
// every public static method should be documented
67-
test('public static methods are documented', () => {
69+
test('public static methods are documented', (t) => {
6870
const documented = new Set(Object.keys(api.statics))
6971
Object.getOwnPropertyNames(spacetime)
7072
.filter((k) => !['length', 'name', 'prototype'].includes(k) && typeof spacetime[k] === 'function')
7173
.forEach((k) => {
7274
if (staticUndocumented.has(k)) {
7375
return
7476
}
75-
assert.ok(documented.has(k), `spacetime.${k} is documented in api/index.js`)
77+
t.ok(documented.has(k), `spacetime.${k} is documented in api/index.js`)
7678
})
79+
t.end()
7780
})

test/clone.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { test } from 'node:test'
2-
import assert from './lib/assert.js'
1+
import test from 'tape'
32
import spacetime from './lib/index.js'
43

5-
test('clone', () => {
4+
test('clone', (t) => {
65
let a = spacetime('March 18, 1999 23:42:00', 'Canada/Eastern')
76
let b = a.clone()
8-
assert.equal(a.date(), 18, 'start-date')
9-
assert.equal(a.hour(), 23, 'start hour')
10-
assert.equal(a.isSame(b, 'hour'), true, 'same-hour')
7+
t.equal(a.date(), 18, 'start-date')
8+
t.equal(a.hour(), 23, 'start hour')
9+
t.equal(a.isSame(b, 'hour'), true, 'same-hour')
1110

1211
a = a.hour(7)
13-
assert.equal(a.hour(), 7, 'new-hour')
14-
assert.equal(b.hour(), 23, 'old-hour')
12+
t.equal(a.hour(), 7, 'new-hour')
13+
t.equal(b.hour(), 23, 'old-hour')
1514

1615
b = b.date(17)
17-
assert.equal(b.date(), 17, 'new-date')
18-
assert.equal(a.date(), 18, 'old-date')
16+
t.equal(b.date(), 17, 'new-date')
17+
t.equal(a.date(), 18, 'old-date')
1918

19+
t.end()
2020
})

0 commit comments

Comments
 (0)