Skip to content

Commit be74376

Browse files
committed
remove
1 parent 7093eff commit be74376

File tree

3 files changed

+128
-1
lines changed

3 files changed

+128
-1
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
4+
import { generateFileList } from '../generateFileList.mjs';
5+
6+
describe('generateFileList', () => {
7+
it('should transform test.js files with updated require paths', () => {
8+
const codeBlocks = [
9+
{
10+
name: 'test.js',
11+
content: "const addon = require('./build/Release/addon');",
12+
},
13+
];
14+
15+
const result = generateFileList(codeBlocks);
16+
const testFile = result.find(file => file.name === 'test.js');
17+
18+
assert(testFile.content.includes("'use strict';"));
19+
assert(testFile.content.includes('`./build/${common.buildType}/addon`'));
20+
assert(!testFile.content.includes("'./build/Release/addon'"));
21+
});
22+
23+
it('should preserve other files unchanged', () => {
24+
const codeBlocks = [{ name: 'addon.cc', content: '#include <node.h>' }];
25+
26+
const result = generateFileList(codeBlocks);
27+
28+
assert.equal(
29+
result.find(file => file.name === 'addon.cc').content,
30+
'#include <node.h>'
31+
);
32+
});
33+
34+
it('should add binding.gyp file', () => {
35+
const codeBlocks = [{ name: 'addon.cc', content: 'code' }];
36+
37+
const result = generateFileList(codeBlocks);
38+
const bindingFile = result.find(file => file.name === 'binding.gyp');
39+
40+
assert(bindingFile);
41+
const config = JSON.parse(bindingFile.content);
42+
assert.equal(config.targets[0].target_name, 'addon');
43+
assert(config.targets[0].sources.includes('addon.cc'));
44+
});
45+
46+
it('should handle empty input', () => {
47+
const result = generateFileList([]);
48+
49+
assert.equal(result.length, 1);
50+
assert.equal(result[0].name, 'binding.gyp');
51+
});
52+
});
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
4+
import {
5+
isBuildableSection,
6+
normalizeSectionName,
7+
generateSectionFolderName,
8+
} from '../section.mjs';
9+
10+
describe('isBuildableSection', () => {
11+
it('should return true when both .cc and .js files are present', () => {
12+
const codeBlocks = [
13+
{ name: 'addon.cc', content: 'C++ code' },
14+
{ name: 'test.js', content: 'JS code' },
15+
];
16+
17+
assert.equal(isBuildableSection(codeBlocks), true);
18+
});
19+
20+
it('should return false when only .cc file is present', () => {
21+
const codeBlocks = [{ name: 'addon.cc', content: 'C++ code' }];
22+
23+
assert.equal(isBuildableSection(codeBlocks), false);
24+
});
25+
26+
it('should return false when only .js file is present', () => {
27+
const codeBlocks = [{ name: 'test.js', content: 'JS code' }];
28+
29+
assert.equal(isBuildableSection(codeBlocks), false);
30+
});
31+
32+
it('should return false for empty array', () => {
33+
assert.equal(isBuildableSection([]), false);
34+
});
35+
});
36+
37+
describe('normalizeSectionName', () => {
38+
it('should convert to lowercase and replace spaces with underscores', () => {
39+
assert.equal(normalizeSectionName('Hello World'), 'hello_world');
40+
});
41+
42+
it('should remove non-word characters', () => {
43+
assert.equal(normalizeSectionName('Test-Section!@#'), 'testsection');
44+
});
45+
46+
it('should handle empty string', () => {
47+
assert.equal(normalizeSectionName(''), '');
48+
});
49+
50+
it('should handle mixed cases and special characters', () => {
51+
assert.equal(
52+
normalizeSectionName('My Test & Example #1'),
53+
'my_test__example_1'
54+
);
55+
});
56+
});
57+
58+
describe('generateSectionFolderName', () => {
59+
it('should generate folder name with padded index', () => {
60+
assert.equal(generateSectionFolderName('hello_world', 0), '01_hello_world');
61+
});
62+
63+
it('should pad single digit indices', () => {
64+
assert.equal(generateSectionFolderName('test', 5), '06_test');
65+
});
66+
67+
it('should not pad double digit indices', () => {
68+
assert.equal(generateSectionFolderName('example', 15), '16_example');
69+
});
70+
71+
it('should handle empty section name', () => {
72+
assert.equal(generateSectionFolderName('', 0), '01_');
73+
});
74+
});

src/generators/man-page/utils/__tests__/converter.test.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ describe('Mandoc Conversion', () => {
5252
input: u('list', [
5353
u('listItem', [textNode('Item 1')]),
5454
u('listItem', [textNode('Item 2')]),
55+
u('link', [textNode('Item 3')]),
5556
]),
56-
expected: '.Bl -bullet\n.It\nItem 1\n.It\nItem 2\n.El',
57+
expected: '.Bl -bullet\n.It\nItem 1\n.It\nItem 2\nItem 3\n.El',
5758
},
5859
{
5960
input: u('code', 'const a = 1;'),

0 commit comments

Comments
 (0)