Skip to content

Commit

Permalink
fix formatring
Browse files Browse the repository at this point in the history
  • Loading branch information
arturgawlik committed Dec 15, 2024
1 parent 11eb1d7 commit ea46fdc
Showing 1 changed file with 64 additions and 64 deletions.
128 changes: 64 additions & 64 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,93 +3,93 @@ const { test } = require("node:test");
const { match, doesNotMatch, strictEqual } = require("node:assert");

test("should work as a loader", async () => {
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-strip.mjs",
fixturesPath("hello.ts"),
]);
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-strip.mjs",
fixturesPath("hello.ts"),
]);

strictEqual(result.stderr, "");
match(result.stdout, /Hello, TypeScript!/);
strictEqual(result.code, 0);
strictEqual(result.stderr, "");
match(result.stdout, /Hello, TypeScript!/);
strictEqual(result.code, 0);
});

test("should not work with enums", async () => {
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-strip.mjs",
fixturesPath("enum.ts"),
]);
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-strip.mjs",
fixturesPath("enum.ts"),
]);

strictEqual(result.stdout, "");
match(result.stderr, /TypeScript enum is not supported in strip-only mode/);
strictEqual(result.code, 1);
strictEqual(result.stdout, "");
match(result.stderr, /TypeScript enum is not supported in strip-only mode/);
strictEqual(result.code, 1);
});

test("should work with enums", async () => {
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-transform.mjs",
fixturesPath("enum.ts"),
]);
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-transform.mjs",
fixturesPath("enum.ts"),
]);

match(result.stdout, /Hello, TypeScript!/);
strictEqual(result.stderr, "");
strictEqual(result.code, 0);
match(result.stdout, /Hello, TypeScript!/);
strictEqual(result.stderr, "");
strictEqual(result.code, 0);
});

test("should warn and inaccurate stracktrace", async () => {
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--import=./dist/register-transform.mjs",
fixturesPath("stacktrace.ts"),
]);
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--import=./dist/register-transform.mjs",
fixturesPath("stacktrace.ts"),
]);

strictEqual(result.stdout, "");
match(result.stderr, /Source maps are disabled/);
match(result.stderr, /stacktrace.ts:5:7/); // inaccurate
strictEqual(result.code, 1);
strictEqual(result.stdout, "");
match(result.stderr, /Source maps are disabled/);
match(result.stderr, /stacktrace.ts:5:7/); // inaccurate
strictEqual(result.code, 1);
});

test("should not warn and accurate stracktrace", async () => {
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--enable-source-maps",
"--import=./dist/register-transform.mjs",
fixturesPath("stacktrace.ts"),
]);
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--enable-source-maps",
"--import=./dist/register-transform.mjs",
fixturesPath("stacktrace.ts"),
]);

doesNotMatch(result.stderr, /Source maps are disabled/);
strictEqual(result.stdout, "");
match(result.stderr, /stacktrace.ts:4:7/); // accurate
strictEqual(result.code, 1);
doesNotMatch(result.stderr, /Source maps are disabled/);
strictEqual(result.stdout, "");
match(result.stderr, /stacktrace.ts:4:7/); // accurate
strictEqual(result.code, 1);
});

test("should call nextLoader for non-typescript files for striping", async () => {
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-strip.mjs",
fixturesPath("hello.js"),
]);
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-strip.mjs",
fixturesPath("hello.js"),
]);

strictEqual(result.stderr, "");
match(result.stdout, /Hello, JavaScript!/);
strictEqual(result.code, 0);
strictEqual(result.stderr, "");
match(result.stdout, /Hello, JavaScript!/);
strictEqual(result.code, 0);
});

test("should call nextLoader for non-typescript files for transform", async () => {
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-transform.mjs",
fixturesPath("hello.js"),
]);
const result = await spawnPromisified(process.execPath, [
"--experimental-strip-types",
"--no-warnings",
"--import=./dist/register-transform.mjs",
fixturesPath("hello.js"),
]);

strictEqual(result.stderr, "");
match(result.stdout, /Hello, JavaScript!/);
strictEqual(result.code, 0);
strictEqual(result.stderr, "");
match(result.stdout, /Hello, JavaScript!/);
strictEqual(result.code, 0);
});

0 comments on commit ea46fdc

Please sign in to comment.