From c2e27127636943cbad3a79b2d933e51a81e2f25e Mon Sep 17 00:00:00 2001 From: Lars Kappert Date: Wed, 23 Oct 2024 09:07:01 +0200 Subject: [PATCH] Add coverage for unused files with compiler extension --- packages/knip/fixtures/compilers/unused.css | 0 packages/knip/fixtures/compilers/unused.md | 0 packages/knip/test/compilers.test.ts | 12 ++++++++---- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 packages/knip/fixtures/compilers/unused.css create mode 100644 packages/knip/fixtures/compilers/unused.md diff --git a/packages/knip/fixtures/compilers/unused.css b/packages/knip/fixtures/compilers/unused.css new file mode 100644 index 000000000..e69de29bb diff --git a/packages/knip/fixtures/compilers/unused.md b/packages/knip/fixtures/compilers/unused.md new file mode 100644 index 000000000..e69de29bb diff --git a/packages/knip/test/compilers.test.ts b/packages/knip/test/compilers.test.ts index 9c9913e93..74c98a29f 100644 --- a/packages/knip/test/compilers.test.ts +++ b/packages/knip/test/compilers.test.ts @@ -1,21 +1,25 @@ import { test } from 'bun:test'; import assert from 'node:assert/strict'; import { main } from '../src/index.js'; -import { resolve } from '../src/util/path.js'; +import { join, resolve } from '../src/util/path.js'; import baseArguments from './helpers/baseArguments.js'; import baseCounters from './helpers/baseCounters.js'; const cwd = resolve('fixtures/compilers'); test('Support compiler functions in config', async () => { - const { counters } = await main({ + const { issues, counters } = await main({ ...baseArguments, cwd, }); + assert(issues.files.has(join(cwd, 'unused.css'))); + assert(issues.files.has(join(cwd, 'unused.md'))); + assert.deepEqual(counters, { ...baseCounters, - processed: 7, - total: 7, + files: 2, + processed: 9, + total: 9, }); });