Skip to content

Commit

Permalink
chore: lint test files as well (#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 16, 2023
1 parent 4d286ad commit d60c0fb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 34 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"dev": "pnpm nitro dev playground",
"dev:build": "pnpm nitro build playground",
"dev:start": "node playground/.output/server/index.mjs",
"lint": "eslint --cache --ext .ts,.mjs,.cjs . && prettier -c src",
"lint:fix": "eslint --cache --fix --ext .ts,.mjs,.cjs . && prettier --write -c src",
"lint": "eslint --cache --ext .ts,.mjs,.cjs . && prettier -c src test",
"lint:fix": "eslint --cache --fix --ext .ts,.mjs,.cjs . && prettier --write -c src test",
"nitro": "NODE_OPTIONS=\"--enable-source-maps\" jiti ./src/cli/cli.ts",
"prepack": "pnpm build",
"release": "pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/api/serialized/function.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default defineEventHandler(() => {
return { foo: () => 'foo' }
return { foo: () => "foo" };
});
12 changes: 6 additions & 6 deletions test/fixture/routes/file.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useStorage } from "#internal/nitro"
import { useStorage } from "#internal/nitro";

export default defineEventHandler(async (event) => {
const query = getQuery(event)
const filename = query?.filename || "index.html"
const serverAsset = await useStorage().getItem(`assets/files/${filename}`)
return serverAsset
})
const query = getQuery(event);
const filename = query?.filename || "index.html";
const serverAsset = await useStorage().getItem(`assets/files/${filename}`);
return serverAsset;
});
53 changes: 28 additions & 25 deletions test/presets/deno-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,31 @@ const hasDeno =
execaCommandSync("deno --version", { stdio: "ignore", reject: false })
.exitCode === 0;

describe.runIf(hasDeno && false /* h3 latest needed */)("nitro:preset:deno-server", async () => {
const ctx = await setupTest("deno-server");
testNitro(ctx, async () => {
const port = await getRandomPort();
const p = execa(
"deno",
["task", "--config", resolve(ctx.outDir, "deno.json"), "start"],
{
stdio: "inherit",
env: {
PORT: String(port),
},
}
);
ctx.server = {
url: `http://127.0.0.1:${port}`,
close: () => p.kill(),
} as any;
await waitForPort(port, { delay: 1000, retries: 20 });
return async ({ url, ...opts }) => {
const res = await ctx.fetch(url, opts);
return res;
};
});
});
describe.runIf(hasDeno && false /* h3 latest needed */)(
"nitro:preset:deno-server",
async () => {
const ctx = await setupTest("deno-server");
testNitro(ctx, async () => {
const port = await getRandomPort();
const p = execa(
"deno",
["task", "--config", resolve(ctx.outDir, "deno.json"), "start"],
{
stdio: "inherit",
env: {
PORT: String(port),
},
}
);
ctx.server = {
url: `http://127.0.0.1:${port}`,
close: () => p.kill(),
} as any;
await waitForPort(port, { delay: 1000, retries: 20 });
return async ({ url, ...opts }) => {
const res = await ctx.fetch(url, opts);
return res;
};
});
}
);

0 comments on commit d60c0fb

Please sign in to comment.