forked from nodejs/doc-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.test.mjs
More file actions
26 lines (20 loc) · 814 Bytes
/
file.test.mjs
File metadata and controls
26 lines (20 loc) · 814 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
'use strict';
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { withExt } from '../file.mjs';
describe('withExt', () => {
it('should replace an existing extension', () => {
assert.strictEqual(withExt('file.md', 'html'), 'file.html');
assert.strictEqual(withExt('path/to/file.md', 'json'), 'path/to/file.json');
});
it('should add an extension when there is none', () => {
assert.strictEqual(withExt('file', 'html'), 'file.html');
});
it('should strip the extension when ext is empty', () => {
assert.strictEqual(withExt('file.md', ''), 'file');
assert.strictEqual(withExt('file.md'), 'file');
});
it('should handle files with multiple dots', () => {
assert.strictEqual(withExt('file.test.mjs', 'js'), 'file.test.js');
});
});