Skip to content

Commit

Permalink
test(core): #373 remove tests with mocked directory separator
Browse files Browse the repository at this point in the history
We now run CI tests on Windows, so we no longer need the mocked path tests.
  • Loading branch information
sdorra committed Nov 2, 2024
1 parent 6652063 commit e305823
Showing 1 changed file with 25 additions and 77 deletions.
102 changes: 25 additions & 77 deletions packages/core/src/writer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,81 +131,29 @@ describe("writer", () => {
expect(existsSync(path.join(tmpdir, "index.d.ts"))).toBe(false);
});

describe("os specific", () => {
tmpdirTest(
"should write import with / instead of \\ on windows",
async ({ tmpdir }) => {
vitest.mock("node:path", async (importOriginal) => {
const origin = await importOriginal<typeof import("node:path")>();
return {
default: {
...origin,
sep: origin.win32.sep,
relative: origin.win32.relative,
},
};
});

const collections = [
{
name: "test",
typeName: "Test",
},
];

const writer = await createWriter(tmpdir);
await writer.createTypeDefinitionFile({
collections,
path: path.join(tmpdir, "sub", "config.ts"),
generateTypes: true,
});

const content = await fs.readFile(
path.join(tmpdir, "index.d.ts"),
"utf-8",
);
expect(content).toContain(
'import configuration from "./sub/config.ts";',
);
},
);

tmpdirTest(
"should write import with / on posix based systems",
async ({ tmpdir }) => {
vitest.mock("node:path", async (importOriginal) => {
const origin = await importOriginal<typeof import("node:path")>();
return {
default: {
...origin,
sep: origin.posix.sep,
relative: origin.posix.relative,
},
};
});

const collections = [
{
name: "test",
typeName: "Test",
},
];

const writer = await createWriter(tmpdir);
await writer.createTypeDefinitionFile({
collections,
path: path.join(tmpdir, "sub", "config.ts"),
generateTypes: true,
});

const content = await fs.readFile(
path.join(tmpdir, "index.d.ts"),
"utf-8",
);
expect(content).toContain(
'import configuration from "./sub/config.ts";',
);
},
);
});
tmpdirTest("should write import with /", async ({ tmpdir }) => {
const collections = [
{
name: "test",
typeName: "Test",
},
];

const writer = await createWriter(tmpdir);
await writer.createTypeDefinitionFile({
collections,
path: path.join(tmpdir, "sub", "config.ts"),
generateTypes: true,
});

const content = await fs.readFile(
path.join(tmpdir, "index.d.ts"),
"utf-8",
);
expect(content).toContain(
'import configuration from "./sub/config.ts";',
);
},
);

});

0 comments on commit e305823

Please sign in to comment.