-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbuildContent.test.mjs
More file actions
68 lines (52 loc) · 1.91 KB
/
buildContent.test.mjs
File metadata and controls
68 lines (52 loc) · 1.91 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
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { setConfig } from '../../../../utils/configuration/index.mjs';
import { transformHeadingNode } from '../buildContent.mjs';
const heading = {
type: 'heading',
depth: 3,
data: { type: 'misc', slug: 's', text: 'Heading' },
children: [{ type: 'text', value: 'Heading' }],
};
const makeParent = typeText => ({
children: [
heading,
{
type: 'paragraph',
children: [{ type: 'text', value: `Type: ${typeText}` }],
},
],
});
await setConfig({});
describe('transformHeadingNode (deprecation Type -> AlertBox level)', () => {
it('maps documentation/compilation to info', () => {
const entry = { api: 'deprecations' };
const parent = makeParent('Documentation');
const node = parent.children[0];
transformHeadingNode(entry, node, 0, parent);
const alert = parent.children[1];
const levelAttr = alert.attributes.find(a => a.name === 'level');
assert.equal(alert.name, 'AlertBox');
assert.equal(levelAttr.value, 'info');
});
it('maps runtime/application to warning', () => {
const entry = { api: 'deprecations' };
const parent = makeParent('Runtime');
const node = parent.children[0];
transformHeadingNode(entry, node, 0, parent);
const alert = parent.children[1];
const levelAttr = alert.attributes.find(a => a.name === 'level');
assert.equal(alert.name, 'AlertBox');
assert.equal(levelAttr.value, 'warning');
});
it('falls back to danger for unknown types', () => {
const entry = { api: 'deprecations' };
const parent = makeParent('SomeOtherThing');
const node = parent.children[0];
transformHeadingNode(entry, node, 0, parent);
const alert = parent.children[1];
const levelAttr = alert.attributes.find(a => a.name === 'level');
assert.equal(alert.name, 'AlertBox');
assert.equal(levelAttr.value, 'danger');
});
});