This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathmetalsmith-hierarchy.test.js
254 lines (249 loc) · 6.85 KB
/
metalsmith-hierarchy.test.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
const $ = require("cheerio");
const md = require("markdown-it")({ typographer: true, html: true });
const firstParagraph = (file) => {
const contents = file.contents.toString("utf-8");
console.log(contents.split(/\r?\n/g));
return $("p", md.render(contents)).first();
};
const newFirstParagraph = (file) => {
const contents = file.contents
.toString("utf-8")
.split(/\r?\n/g)
.filter((n) => n);
return contents[0] || "";
};
const cases = [
[
"Learn about D2iQ products, from installation to operations, and deploying your workloads.",
{
layout: "all-products-landing.pug",
navigationTitle: "D2iQ Documentation",
title: "D2iQ Documentation",
enterprise: false,
menuWeight: 0,
contents:
"Learn about D2iQ products, from installation to operations, and deploying your workloads.\n",
mode: "0644",
stats: {
dev: 16777221,
mode: 33188,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 5572034,
size: 225,
blocks: 8,
atimeMs: 1625854220814.8652,
mtimeMs: 1625844885892.827,
ctimeMs: 1625844885892.827,
birthtimeMs: 1625844885892.7776,
atime: "2021-07-09T18:10:20.815Z",
mtime: "2021-07-09T15:34:45.893Z",
ctime: "2021-07-09T15:34:45.893Z",
birthtime: "2021-07-09T15:34:45.893Z",
},
},
],
[
"",
{
layout: "404.pug",
title: "Page not found",
navigationTitle: 404,
menuWeight: -1,
contents: "\n",
mode: "0644",
stats: {
dev: 16777221,
mode: 33188,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 5567604,
size: 83,
blocks: 8,
atimeMs: 1625854220789.7256,
mtimeMs: 1625844884575.6018,
ctimeMs: 1625844884575.6018,
birthtimeMs: 1625844884575.5493,
atime: "2021-07-09T18:10:20.790Z",
mtime: "2021-07-09T15:34:44.576Z",
ctime: "2021-07-09T15:34:44.576Z",
birthtime: "2021-07-09T15:34:44.576Z",
},
},
],
[
"",
{
layout: "search.pug",
title: "Search",
navigationTitle: "Search",
menuWeight: -1,
contents: "",
mode: "0644",
stats: {
dev: 16777221,
mode: 33188,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 5588358,
size: 80,
blocks: 8,
atimeMs: 1625844954693.5637,
mtimeMs: 1625844889836.079,
ctimeMs: 1625844889836.079,
birthtimeMs: 1625844889836.0042,
atime: "2021-07-09T15:35:54.694Z",
mtime: "2021-07-09T15:34:49.836Z",
ctime: "2021-07-09T15:34:49.836Z",
birthtime: "2021-07-09T15:34:49.836Z",
},
},
],
[
"Welcome to DKP",
{
layout: "konvoy-docs-landing.pug",
navigationTitle: "D2iQ Kubernetes Platform",
title: "D2iQ Kubernetes Platform",
menus: ["landing-header"],
menuWeight: 5,
contents: "\nWelcome to DKP\n",
mode: "0644",
stats: {
dev: 16777221,
mode: 33188,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 5568156,
size: 170,
blocks: 8,
atimeMs: 1625854220806.4666,
mtimeMs: 1625844884628.3464,
ctimeMs: 1625844884628.3464,
birthtimeMs: 1625844884628.2947,
atime: "2021-07-09T18:10:20.806Z",
mtime: "2021-07-09T15:34:44.628Z",
ctime: "2021-07-09T15:34:44.628Z",
birthtime: "2021-07-09T15:34:44.628Z",
},
},
],
[
"The following information describes mitigated or fixed CVEs found in Konvoy.",
{
layout: "layout.pug",
navigationTitle: "Security Updates",
title: "Security Updates",
excerpt: "View CVE security scans and update information for Konvoy",
menuWeight: 1000,
beta: false,
contents:
'\nThe following information describes mitigated or fixed CVEs found in Konvoy.\n\n<div class="cve-table-container">Loading...</div>\n<script src="/js/cve.js"></script>\n\n',
mode: "0644",
stats: {
dev: 16777221,
mode: 33188,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 5572033,
size: 346,
blocks: 8,
atimeMs: 1625854220814.8523,
mtimeMs: 1625844885892.725,
ctimeMs: 1625844885892.725,
birthtimeMs: 1625844885892.6711,
atime: "2021-07-09T18:10:20.815Z",
mtime: "2021-07-09T15:34:45.893Z",
ctime: "2021-07-09T15:34:45.893Z",
birthtime: "2021-07-09T15:34:45.893Z",
},
},
],
[
"",
{
layout: "conductor-docs-landing.pug",
navigationTitle: "Conductor",
title: "Conductor",
menuWeight: 1,
beta: false,
menus: ["conductor-header"],
contents: "",
mode: "0644",
stats: {
dev: 16777221,
mode: 33188,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 5567647,
size: 141,
blocks: 8,
atimeMs: 1625854220791.1025,
mtimeMs: 1625844884578.9888,
ctimeMs: 1625844884578.9888,
birthtimeMs: 1625844884578.9385,
atime: "2021-07-09T18:10:20.791Z",
mtime: "2021-07-09T15:34:44.579Z",
ctime: "2021-07-09T15:34:44.579Z",
birthtime: "2021-07-09T15:34:44.579Z",
},
},
],
[
"Conductor is a an interactive learning platform designed to accelerate onboarding to cloud-native technologies through focusing on hands-on-experience that enhances acquiring learning objectives.",
{
layout: "layout.pug",
navigationTitle: "Welcome to Conductor 1.0",
title: "Welcome to Conductor 1.0",
beta: false,
menuWeight: 15,
contents:
"\nConductor is a an interactive learning platform designed to accelerate onboarding to cloud-native technologies through focusing on hands-on-experience that enhances acquiring learning objectives.",
mode: "0644",
stats: {
dev: 16777221,
mode: 33188,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 5567610,
size: 325,
blocks: 8,
atimeMs: 1625854220790.1133,
mtimeMs: 1625844884576.042,
ctimeMs: 1625844884576.042,
birthtimeMs: 1625844884575.9734,
atime: "2021-07-09T18:10:20.790Z",
mtime: "2021-07-09T15:34:44.576Z",
ctime: "2021-07-09T15:34:44.576Z",
birthtime: "2021-07-09T15:34:44.576Z",
},
},
],
];
describe("firstParagraph func", () => {
test.each(cases)("should return the expected value", (expected, file) => {
const actual = newFirstParagraph(file);
expect(actual).toEqual(expected);
});
});