MCPcopy
hub / github.com/visgl/deck.gl / test

Function test

scripts/write-heading-ids.ts:43–78  ·  view source on GitHub ↗

Test that getCustomId handles different formats correctly

()

Source from the content-addressed store, hash-verified

41
42/** Test that getCustomId handles different formats correctly */
43function test() {
44 expect(
45 getCustomId(
46 `The line width of each object, in units specified by widthUnits (default pixels). `
47 )?.[2],
48 undefined,
49 'not header'
50 );
51 expect(getCustomId(`## Learning deck.gl`)?.[2], undefined, 'does not contain code');
52 expect(getCustomId(`## Changes to \`TileLayer\``)?.[2], undefined, 'is not api');
53 expect(getCustomId(`## \`pickObjects\``)?.[2], '{#pickobjects}', 'single word api');
54 expect(getCustomId(`## \`@deck.gl/extensions\``)?.[2], undefined, 'Package name');
55 expect(
56 getCustomId(`## \`strokeOpacity\` (Number)`)?.[2],
57 '{#strokeopacity}',
58 'with type annotation 1'
59 );
60 expect(
61 getCustomId(`## \`backgroundPadding:number[]\``)?.[2],
62 '{#backgroundpadding}',
63 'with type annotation 2'
64 );
65 expect(
66 getCustomId(`## \`onBeforeRender(gl: WebGLRenderingContext)\``)?.[2],
67 '{#onbeforerender}',
68 'with call signature'
69 );
70 expect(
71 getCustomId(
72 `##### \`getWidth\` ([Function](../../developer-guide/using-layers.md#accessors)|Number, optional) ![transition-enabled](https://img.shields.io/badge/transition-enabled-green.svg?style=flat-square")`
73 )?.[2],
74 '{#getwidth}',
75 'with extra flag'
76 );
77 console.log('All tests pass!\n');
78}
79
80/** Traverse all files in the docs directory, append custom ids if necessary */
81async function main() {

Calls 2

expectFunction · 0.85
getCustomIdFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…