Skip to content

Commit 6ac3b6f

Browse files
authored
Replace tape with node:test/ node:assert (#225)
* Replace tape with test/assert modules * Remove tape/tap-arc dev dependencies, add CONTRIBUTING.md docs highlighting Node 21 as minimum version for development.
1 parent db06e94 commit 6ac3b6f

Some content is hidden

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

61 files changed

+1212
-1302
lines changed

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Contributing
2+
3+
## Development
4+
5+
Tests are defined using the `node:test` and `node:assert` modules. Running the tests require Node 21 or newer:
6+
7+
```bash
8+
npm run test
9+
```
10+
11+
We use ESLint to lint JavaScript code.
12+
13+
14+
```bash
15+
npm run lint
16+
```
17+
18+
While Culori can be used from source in environments supporting ES Modules, we also use esbuild to build bundles in CommonJS, ESM, and UMD formats.
19+
20+
```bash
21+
npm run build
22+
```
23+
24+
## Documentation
25+
26+
The documentation website [culorijs.org] is built with Eleventy out of the `www/` folder, and deployed on GitHub pages via the `gh-pages` branch.
27+
28+
The following scripts are available:
29+
30+
```bash
31+
npm run docs:start
32+
npm run docs:build
33+
npm run docs:deploy
34+
```

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ The full documentation is published on [culorijs.org](https://culorijs.org). Som
1616

1717
## Contributing
1818

19-
Contributions of any kind (feedback, ideas, bug fixes) are welcome. Please open a GitHub issue before starting work on anything that's not straightforward.
19+
Contributions of all kinds (feedback, ideas, bug fixes, documentation) are welcome.
20+
21+
Please open a GitHub issue/discussion before putting in any work that’s not straightforward.
22+
23+
More in [CONTRIBUTING.md](./CONTRIBUTING.md).

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,11 @@
5454
"eslint-plugin-import": "^2.29.1",
5555
"gh-pages": "^6.1.1",
5656
"prettier": "^3.2.4",
57-
"pretty-quick": "^4.0.0",
58-
"tap-arc": "^1.2.2",
59-
"tape": "^5.7.3"
57+
"pretty-quick": "^4.0.0"
6058
},
6159
"scripts": {
6260
"prepare": "git config core.hooksPath .git-hooks",
63-
"test": "tape 'test/**/*.test.js' | tap-arc",
61+
"test": "node --test 'test/**/*.test.js'",
6462
"start": "npx esbuild --servedir=.",
6563
"build": "node build.js",
6664
"benchmark": "node benchmark/index.js",

test/a98.test.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
import tape from 'tape';
1+
import test from 'node:test';
2+
import assert from 'node:assert';
23
import { a98, rgb, formatCss } from '../src/index.js';
34

4-
tape('a98', t => {
5-
t.deepEqual(
5+
test('a98', t => {
6+
assert.deepEqual(
67
a98('white'),
78
{ mode: 'a98', r: 0.9999999999999999, g: 1, b: 1.0000000000000002 },
89
'white'
910
);
10-
t.deepEqual(a98('black'), { mode: 'a98', r: 0, g: 0, b: 0 }, 'black');
11-
t.deepEqual(
11+
assert.deepEqual(a98('black'), { mode: 'a98', r: 0, g: 0, b: 0 }, 'black');
12+
assert.deepEqual(
1213
a98('red'),
1314
{
1415
mode: 'a98',
@@ -18,42 +19,38 @@ tape('a98', t => {
1819
},
1920
'red'
2021
);
21-
t.end();
2222
});
2323

24-
tape('color(a98-rgb)', t => {
25-
t.deepEqual(a98('color(a98-rgb 1 0 0 / 0.25)'), {
24+
test('color(a98-rgb)', t => {
25+
assert.deepEqual(a98('color(a98-rgb 1 0 0 / 0.25)'), {
2626
r: 1,
2727
g: 0,
2828
b: 0,
2929
alpha: 0.25,
3030
mode: 'a98'
3131
});
32-
t.deepEqual(a98('color(a98-rgb 0% 50% 0.5 / 25%)'), {
32+
assert.deepEqual(a98('color(a98-rgb 0% 50% 0.5 / 25%)'), {
3333
r: 0,
3434
g: 0.5,
3535
b: 0.5,
3636
alpha: 0.25,
3737
mode: 'a98'
3838
});
39-
t.end();
4039
});
4140

42-
tape('formatCss', t => {
43-
t.equal(
41+
test('formatCss', t => {
42+
assert.equal(
4443
formatCss('color(a98-rgb 0% 50% 0.5 / 25%)'),
4544
'color(a98-rgb 0 0.5 0.5 / 0.25)'
4645
);
47-
t.end();
4846
});
4947

50-
tape('missing components', t => {
51-
t.ok(rgb('color(a98-rgb none 0.5 none)'), 'a98 to rgb is ok');
52-
t.deepEqual(
48+
test('missing components', t => {
49+
assert.ok(rgb('color(a98-rgb none 0.5 none)'), 'a98 to rgb is ok');
50+
assert.deepEqual(
5351
rgb('color(a98-rgb none 0.5 none)'),
5452
rgb('color(a98-rgb 0 0.5 0')
5553
);
56-
t.ok(a98('rgb(none 100 20)'), 'rgb to a98 is ok');
57-
t.deepEqual(a98('rgb(none 100 20)'), a98('rgb(0 100 20)'));
58-
t.end();
54+
assert.ok(a98('rgb(none 100 20)'), 'rgb to a98 is ok');
55+
assert.deepEqual(a98('rgb(none 100 20)'), a98('rgb(0 100 20)'));
5956
});

test/api.test.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/*
22
Keep an eye on the API surface of the various bundles
33
*/
4-
import tape from 'tape';
4+
import test from 'node:test';
5+
import assert from 'node:assert';
56

67
import * as full from '../src/index.js';
78
import * as css from '../src/bootstrap/css.js';
@@ -474,22 +475,18 @@ const API_FN = [
474475
'wcagLuminance'
475476
];
476477

477-
tape('culori', t => {
478-
t.deepEqual(Object.keys(full).sort(), API_FULL.sort());
479-
t.end();
478+
test('culori', t => {
479+
assert.deepEqual(Object.keys(full).sort(), API_FULL.sort());
480480
});
481481

482-
tape('culori/css', t => {
483-
t.deepEqual(Object.keys(css).sort(), API_CSS.sort());
484-
t.end();
482+
test('culori/css', t => {
483+
assert.deepEqual(Object.keys(css).sort(), API_CSS.sort());
485484
});
486485

487-
tape('culori/all', t => {
488-
t.deepEqual(Object.keys(all).sort(), API_ALL.sort());
489-
t.end();
486+
test('culori/all', t => {
487+
assert.deepEqual(Object.keys(all).sort(), API_ALL.sort());
490488
});
491489

492-
tape('culori/fn', t => {
493-
t.deepEqual(Object.keys(fn).sort(), API_FN.sort());
494-
t.end();
490+
test('culori/fn', t => {
491+
assert.deepEqual(Object.keys(fn).sort(), API_FN.sort());
495492
});

test/average.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import tape from 'tape';
1+
import test from 'node:test';
2+
import assert from 'node:assert';
23
import { average, averageAngle, formatHex } from '../src/index.js';
34

4-
tape('average', t => {
5-
t.equal(formatHex(average(['#ff0000', '#0000ff'])), '#800080');
6-
t.equal(formatHex(average(['#ff0000', '#0000ff'], 'lch')), '#f50086');
7-
t.end();
5+
test('average', t => {
6+
assert.equal(formatHex(average(['#ff0000', '#0000ff'])), '#800080');
7+
assert.equal(formatHex(average(['#ff0000', '#0000ff'], 'lch')), '#f50086');
88
});
99

10-
tape('averageAngle', t => {
11-
t.equal(averageAngle([270, 0]), 315);
12-
t.end();
10+
test('averageAngle', t => {
11+
assert.equal(averageAngle([270, 0]), 315);
1312
});

test/blend.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import tape from 'tape';
1+
import test from 'node:test';
2+
import assert from 'node:assert';
23
import { blend } from '../src/index.js';
34

4-
tape('blendNormal', function (test) {
5-
test.deepEqual(blend(['white', 'rgba(0, 0, 0, 0.5)']), {
5+
test('blendNormal', t => {
6+
assert.deepEqual(blend(['white', 'rgba(0, 0, 0, 0.5)']), {
67
mode: 'rgb',
78
r: 0.5,
89
g: 0.5,
910
b: 0.5,
1011
alpha: 1
1112
});
1213

13-
test.deepEqual(
14+
assert.deepEqual(
1415
blend([
1516
{ mode: 'rgb', r: 1, g: 0, b: 0, alpha: 0.5 },
1617
{ mode: 'rgb', r: 0, g: 0, b: 1, alpha: 0.5 }
@@ -25,16 +26,14 @@ tape('blendNormal', function (test) {
2526
);
2627

2728
// blend with transparent source
28-
test.deepEqual(
29+
assert.deepEqual(
2930
blend([{ mode: 'rgb', r: 1, g: 0, b: 0, alpha: 0.5 }, 'transparent']),
3031
{ mode: 'rgb', r: 1, g: 0, b: 0, alpha: 0.5 }
3132
);
3233

3334
// blend with transparent backdrop
34-
test.deepEqual(
35+
assert.deepEqual(
3536
blend(['transparent', { mode: 'rgb', r: 1, g: 0, b: 0, alpha: 0.5 }]),
3637
{ mode: 'rgb', r: 1, g: 0, b: 0, alpha: 0.5 }
3738
);
38-
39-
test.end();
4039
});

test/cat.test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import tape from 'tape';
1+
import test from 'node:test';
2+
import assert from 'node:assert';
23
import { xyz65, xyz50, rgb } from '../src/index.js';
34

45
let colors = ['red', 'green', 'blue', 'white', 'black', 'magenta', 'tomato'];
@@ -22,16 +23,14 @@ let sameRGB = (a, b) => {
2223
);
2324
};
2425

25-
tape('rgb -> xyz50 = rgb -> xyz65 -> xyz50', t => {
26+
test('rgb -> xyz50 = rgb -> xyz65 -> xyz50', t => {
2627
colors.forEach(c => {
27-
t.ok(sameXYZ(xyz50(rgb(c)), xyz50(xyz65(rgb(c)))), c);
28+
assert.ok(sameXYZ(xyz50(rgb(c)), xyz50(xyz65(rgb(c)))), c);
2829
});
29-
t.end();
3030
});
3131

32-
tape('rgb -> xyz50 -> rgb = rgb -> xyz50 -> xyz65 -> rgb', t => {
32+
test('rgb -> xyz50 -> rgb = rgb -> xyz50 -> xyz65 -> rgb', t => {
3333
colors.forEach(c => {
34-
t.ok(sameRGB(rgb(xyz50(rgb(c))), rgb(xyz65(xyz50(rgb(c))))), c);
34+
assert.ok(sameRGB(rgb(xyz50(rgb(c))), rgb(xyz65(xyz50(rgb(c))))), c);
3535
});
36-
t.end();
3736
});

0 commit comments

Comments
 (0)