Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 committed Jul 31, 2024
1 parent 7b7f591 commit b35c5ea
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions e2e/cases/dts/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import { execSync } from 'node:child_process';
import { join } from 'node:path';
import { expect, test } from 'vitest';
import { buildAndGetResults } from '#shared';
import { getResults } from '#shared';
import { loadConfig } from '../../../packages/core/src/config';

test('dts when bundle: false', async () => {
const fixturePath = join(__dirname, 'bundle-false');
const { files } = await buildAndGetResults(fixturePath, 'dts');
const rslibConfig = await loadConfig(join(fixturePath, 'rslib.config.ts'));

execSync('npx rslib build', {
cwd: fixturePath,
});

const { files } = await getResults(rslibConfig, 'dts');

expect(files.esm?.length).toBe(4);
expect(files.esm?.[0]!.endsWith('.d.ts')).toEqual(true);
});

test('dts when bundle: true', async () => {
const fixturePath = join(__dirname, 'bundle');
const { entryFiles } = await buildAndGetResults(fixturePath, 'dts');
const rslibConfig = await loadConfig(join(fixturePath, 'rslib.config.ts'));

execSync('npx rslib build', {
cwd: fixturePath,
});

const { entryFiles } = await getResults(rslibConfig, 'dts');

expect(entryFiles.esm!.endsWith('index.d.ts')).toEqual(true);
});

0 comments on commit b35c5ea

Please sign in to comment.