Skip to content

Commit

Permalink
debug: dynamic sep
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel committed Jun 15, 2024
1 parent e09b505 commit f6d49d9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions test/unit/map-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { nodeVersion } from '../../src/helpers/get-runtime.js';

if (nodeVersion && nodeVersion < 14) process.exit(0);

import { join } from 'node:path';
import { join, sep } from 'node:path';
import { writeFileSync, mkdirSync, rmSync } from 'node:fs';
import { it } from '../../src/modules/it.js';
import { describe } from '../../src/modules/describe.js';
Expand All @@ -23,6 +23,8 @@ const removeDirSync = (dirPath: string) => {
rmSync(dirPath, { recursive: true, force: true });
};

const dsep = (file: string) => file.replace(/[/\\]+/g, sep);

const testSrcDir = 'test-src';
const testTestDir = 'test-tests';

Expand All @@ -45,17 +47,20 @@ describe('mapTests', async () => {
await it('should map test files to their corresponding source files', async () => {
const importMap = await mapTests(testSrcDir, [testTestDir]);
const expected = new Map([
['test-src/example.js', ['test-tests/example.test.js']],
[dsep('test-src/example.js'), [dsep('test-tests/example.test.js')]],
]);

console.log(importMap);
console.log(expected);

assert.deepStrictEqual(importMap, expected);
});

await it('should map single test file correctly', async () => {
const singleTestFile = join(testTestDir, 'example.test.js');
const importMap = await mapTests(testSrcDir, [singleTestFile]);
const expected = new Map([
['test-src/example.js', ['test-tests/example.test.js']],
[dsep('test-src/example.js'), [dsep('test-tests/example.test.js')]],
]);

assert.deepStrictEqual(importMap, expected);
Expand Down

0 comments on commit f6d49d9

Please sign in to comment.