Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions action-src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
"devDependencies": {
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.1",
"@cspell/cspell-types": "^9.3.2",
"@cspell/cspell-types": "^9.4.0",
"@octokit/webhooks-types": "^7.6.1",
"@types/node": "^24.10.1",
"cspell": "^9.3.2",
"cspell-glob": "^9.3.2",
"cspell": "^9.4.0",
"cspell-glob": "^9.4.0",
"esbuild": "^0.27.0",
"vscode-uri": "^3.1.0"
},
"dependencies": {
"@cspell/cspell-bundled-dicts": "^9.3.2"
"@cspell/cspell-bundled-dicts": "^9.4.0"
},
"files": [
"lib",
Expand Down
51 changes: 51 additions & 0 deletions action-src/src/reporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,55 @@ describe('Validate Reporter', () => {
reporter.error?.('This is an error message', new Error('Test error'));
expect(logger.error).toHaveBeenCalledWith(expect.stringContaining('This is an error message'));
});

test.each`
msgType
${'Warning'}
${'Debug'}
${'Info'}
`('Info is ignored $msgType', ({ msgType }) => {
// Currently all "info" messages are ignored.
const logger = createLogger({
debug: vi.fn(),
info: vi.fn(),
warning: vi.fn(),
error: vi.fn(),
});

const actionReporter = new CSpellReporterForGithubAction(
'none',
{ verbose: false, treatFlaggedWordsAsErrors: true },
logger,
);
const reporter = actionReporter.reporter;

reporter.info?.('This is an error message', msgType);
expect(logger.debug).not.toHaveBeenCalled();
expect(logger.error).not.toHaveBeenCalled();
expect(logger.info).not.toHaveBeenCalled();
expect(logger.warning).not.toHaveBeenCalled();
});

test('Debug is ignored', () => {
// Currently all "debug" messages are ignored.
const logger = createLogger({
debug: vi.fn(),
info: vi.fn(),
warning: vi.fn(),
error: vi.fn(),
});

const actionReporter = new CSpellReporterForGithubAction(
'none',
{ verbose: false, treatFlaggedWordsAsErrors: true },
logger,
);
const reporter = actionReporter.reporter;

reporter.debug?.('This is an error message');
expect(logger.debug).not.toHaveBeenCalled();
expect(logger.error).not.toHaveBeenCalled();
expect(logger.info).not.toHaveBeenCalled();
expect(logger.warning).not.toHaveBeenCalled();
});
});
11 changes: 6 additions & 5 deletions action-src/src/spell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ describe('Validate Spell Checking', () => {
files: 0,
filesWithIssues: new Set(),
issues: 0,
// skippedFiles: 0,
};

const sampleConfig = resolveFile('fixtures/cspell.json', sourceDir);
Expand All @@ -106,12 +107,12 @@ describe('Validate Spell Checking', () => {

test.each`
globs | files | options | expected
${[]} | ${['fixtures/sampleCode/ts/sample.ts']} | ${{}} | ${{ files: 1 }}
${['**/*.ts']} | ${['fixtures/sampleCode/ts/sample.ts']} | ${{}} | ${{ files: 1 }}
${[]} | ${['fixtures/sampleCode/ts/sample.ts']} | ${{}} | ${{ files: 1, skippedFiles: 0 }}
${['**/*.ts']} | ${['fixtures/sampleCode/ts/sample.ts']} | ${{}} | ${{ files: 1, skippedFiles: 0 }}
${[]} | ${['fixtures/sampleCode/ts/missing.ts']} | ${{}} | ${{ files: 0 }}
${[]} | ${[]} | ${{}} | ${{ files: 0 }}
${[]} | ${undefined} | ${sampleCodeTsOptions} | ${{ files: 1 }}
${[]} | ${['fixtures/sampleCode/ts/cspell.config.yaml']} | ${{ config: sampleConfig }} | ${{ files: 1 }}
${[]} | ${undefined} | ${sampleCodeTsOptions} | ${{ files: 1, skippedFiles: 0 }}
${[]} | ${['fixtures/sampleCode/ts/cspell.config.yaml']} | ${{ config: sampleConfig }} | ${{ files: 1, skippedFiles: 0 }}
${[]} | ${['fixtures/sampleCode/ts/cspell.config.yaml']} | ${{ config: sampleConfigTs }} | ${{ files: 0 }}
${['**/*.ts']} | ${['fixtures/sampleCode/ts/cspell.config.yaml']} | ${{ config: sampleConfig }} | ${{ files: 0 }}
${['**/ts/missing.ts']} | ${undefined} | ${{}} | ${{ files: 0 }}
Expand Down Expand Up @@ -151,7 +152,7 @@ describe('Validate Spell Checking', () => {
const reporter = new CSpellReporterForGithubAction('warning', { ...rOptions, verbose: false }, logger);
reporter.onIssue = (issue) => issues.push(issue);
await spell.lint(globs, opts, reporter.reporter);
expect(reporter.result).toEqual({ ...defaultResult, ...expected });
expect(reporter.result).toEqual({ ...defaultResult, skippedFiles: 0, ...expected });
expect(issues.map((issue) => issue.text)).toEqual(expectedIssues);
});
});
Expand Down
Loading
Loading