Skip to content

Commit 8d2610f

Browse files
committed
update tests
1 parent 5893496 commit 8d2610f

File tree

5 files changed

+90
-1636
lines changed

5 files changed

+90
-1636
lines changed

src/format/headings.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,41 @@ _headings(
212212
}
213213
);
214214

215+
_headings(
216+
"transforms and formats multi-level headings: level 2 headings",
217+
async () => {
218+
const sections: unknown[] = [];
219+
const src = vFile({
220+
contents: `### script
221+
222+
#### one
223+
224+
#### two
225+
`,
226+
data: {
227+
dir: "docs",
228+
docs_type: "docs",
229+
sections,
230+
section_stack: [sections],
231+
section_title: "component format",
232+
base_level: 3,
233+
prev_level: 3,
234+
slugs: [],
235+
seen_slugs: new Map(),
236+
},
237+
});
238+
239+
const output = await linkify_only(src);
240+
241+
assert.equal(
242+
output.contents,
243+
`<h3><span id="component-format-script" class="offset-anchor"></span><a href="docs#component-format-script" class="anchor" aria-hidden></a>script</h3>
244+
<h4><span id="component-format-script-one" class="offset-anchor"></span><a href="docs#component-format-script-one" class="anchor" aria-hidden></a>one</h4>
245+
<h4><span id="component-format-script-two" class="offset-anchor"></span><a href="docs#component-format-script-two" class="anchor" aria-hidden></a>two</h4>`
246+
);
247+
}
248+
);
249+
215250
strip("strips leading level 1 headings", async () => {
216251
const src = `
217252

src/format/headings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export function linkify_headings(): Transformer {
9797
}
9898

9999
data.slugs.push(slug);
100+
console.log(data.slugs);
100101

101102
// We keep a 'section_stack' to keep track of the section structure
102103
if (node.depth > data.prev_level) {

src/fs/fixtures/output-repo-3.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/fs/fixtures/output-repo-4.js

Lines changed: 1 addition & 1583 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)