forked from nodejs/doc-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplates.test.mjs
More file actions
26 lines (21 loc) · 804 Bytes
/
templates.test.mjs
File metadata and controls
26 lines (21 loc) · 804 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 { populate } from '../templates.mjs';
describe('populate', () => {
it('should substitute template variables from config', () => {
const result = populate('https://github.com/{repository}/blob/{ref}/', {
repository: 'nodejs/node',
ref: 'main',
});
assert.strictEqual(result, 'https://github.com/nodejs/node/blob/main/');
});
it('should use fallback when config value is missing', () => {
const result = populate('{name|unknown}', {});
assert.strictEqual(result, 'unknown');
});
it('should leave the placeholder as-is when no value or fallback', () => {
const result = populate('{missing}', {});
assert.strictEqual(result, '{missing}');
});
});