Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim committed Dec 3, 2022
1 parent 9f90d8a commit 8be0d42
Show file tree
Hide file tree
Showing 6 changed files with 381 additions and 415 deletions.
17 changes: 14 additions & 3 deletions src/__snapshots__/entry.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
// Vitest Snapshot v1

exports[`getEntriesFromContext - in TypeScript project > types entry does not accept nesting 1`] = `"\\"types\\" entry must be .d.ts file and cannot be nested!"`;
exports[`getEntriesFromContext > throw if "main" and "module" is on conflict 1`] = `
"Hint: Did you forgot to set \\"type\\" to 'module' for ESM-first approach?
"
`;

exports[`getEntriesFromContext - in TypeScript project > types entry must has .d.ts extension 1`] = `"\\"types\\" entry must has .d.ts extension!"`;
exports[`getEntriesFromContext - in TypeScript project > types entry does not accept nesting 1`] = `
"\\"types\\" entry must be .d.ts file and cannot be nested!
"
`;

exports[`getEntriesFromContext - in TypeScript project > types entry must occur first in conditional exports 1`] = `"\\"types\\" entry must occur first in conditional exports for correct type resolution."`;
exports[`getEntriesFromContext - in TypeScript project > types entry must has .d.ts extension 1`] = `"Only .d.ts or .d.cts or .d.mts allowed for \\"types\\" entry."`;

exports[`getEntriesFromContext - in TypeScript project > types entry must occur first in conditional exports 1`] = `
"\\"types\\" entry must occur first in conditional exports for correct type resolution.
"
`;
12 changes: 10 additions & 2 deletions src/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ import { type PathResolver } from './common';
import { type Context } from './context';
import { type Flags } from './cli';
import { type Manifest } from './manifest';
import { Reporter } from './reporter';
import { type Reporter } from './reporter';
import { parseConfig } from './context';

class ViReporter implements Reporter {
debug = vi.fn();
info = vi.fn();
warn = vi.fn();
error = vi.fn();
captureException = vi.fn();
}

describe('parseConfig', () => {
const reporter = new Reporter(console);
const reporter = new ViReporter();
const resolve: PathResolver = vi.fn();
const defaultFlags: Flags = {
cwd: '/project',
Expand Down
Loading

0 comments on commit 8be0d42

Please sign in to comment.