Skip to content

Commit e0d3dc2

Browse files
committed
fix tests
1 parent 0057be5 commit e0d3dc2

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

lib/toc-builder.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ function loadToc(contentFolder, dataFolder) {
8484
const files = loadRFCData(contentFolder, dataFolder);
8585

8686
for (let file of files) {
87-
const stage = file.stage;
87+
const stage = file.currentStage;
8888

8989
if (stages[stage]) {
90-
stages[stage].push(file);
90+
stages[stage].push(file.rfcFile);
9191
} else {
92-
stages[stage] = [file];
92+
stages[stage] = [file.rfcFile];
9393
}
9494
}
9595

9696
const outputData = {
97-
links: files,
97+
links: files.map((item) => item.rfcFile),
9898
stages: Object.keys(stages),
9999
stageLinks: stages,
100100
};

node-tests/toc-builder.test.mjs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ describe('Tag Generator', function () {
1414

1515
it('should automatically create a new tag for the most recent 4 posts', async function () {
1616
project.files = {
17+
data: {
18+
'1.json': JSON.stringify({
19+
number: 1,
20+
}),
21+
'2.json': JSON.stringify({
22+
number: 2,
23+
}),
24+
'5.json': JSON.stringify({
25+
number: 5,
26+
}),
27+
'11.json': JSON.stringify({
28+
number: 11,
29+
}),
30+
},
1731
content: {
1832
'0001-transform.md': `---
1933
startDate: 2001
@@ -44,7 +58,13 @@ stage: approved
4458
const bundle = await rollup({
4559
treeshake: false,
4660
input: resolve(project.baseDir, 'index.js'),
47-
plugins: [tocBuilder(resolve(project.baseDir, 'content')), pluginJson()],
61+
plugins: [
62+
tocBuilder(
63+
resolve(project.baseDir, 'content'),
64+
resolve(project.baseDir, 'data'),
65+
),
66+
pluginJson(),
67+
],
4868
});
4969

5070
const { output } = await bundle.generate({ exports: 'auto' });

0 commit comments

Comments
 (0)