Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,37 @@ jobs:
import { strict as assert } from 'node:assert';
import * as utils from './dist/utils.js';

test('detectPackageManager handles edge cases', () => {
const testCases = ['', ' ', 'invalid', '../malicious', null, undefined];
testCases.forEach(input => {
test('detectPackageManager handles edge cases', async () => {
const validTestCases = ['', ' ', 'invalid', '../malicious', '/nonexistent'];
for (const input of validTestCases) {
try {
const result = utils.detectPackageManager(input);
const result = await utils.detectPackageManager(input);
assert.equal(typeof result, 'string');
assert.ok(['npm', 'yarn', 'pnpm', 'bun'].includes(result));
assert.ok(['npm', 'yarn', 'pnpm', 'bun', 'pip', 'poetry', 'uv', 'none'].includes(result));
} catch (error) {
assert.ok(error instanceof Error);
}
});
}

const invalidTestCases = [null, undefined];
for (const input of invalidTestCases) {
try {
await utils.detectPackageManager(input);
assert.fail('Should have thrown for invalid input');
} catch (error) {
assert.ok(error instanceof Error);
}
}
});

test('validateTemplateVariables handles malformed input', () => {
const testCases = [{}, null, undefined, [], 'string'];
testCases.forEach(input => {
try {
const result = utils.validateTemplateVariables(input, []);
assert.equal(typeof result, 'object');
if (result !== null && result !== undefined) {
assert.equal(typeof result, 'object');
}
} catch (error) {
assert.ok(error instanceof Error);
}
Expand Down
Loading