Skip to content

Commit 91219d7

Browse files
committed
cleanup
1 parent d9ab2a0 commit 91219d7

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

tests/helper.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import commandLineUsage from "command-line-usage";
22
import commandLineArgs from "command-line-args";
3-
import serve from "./server.mjs";
3+
import serve, { DEFAULT_CACHE_DURATION } from "./server.mjs";
44

55
import firefox from "selenium-webdriver/firefox.js";
66
import chrome from "selenium-webdriver/chrome.js";
@@ -73,9 +73,8 @@ export default async function testSetup(helpText) {
7373
}
7474
}
7575
const PORT = options.port;
76-
const CACHE_DURATION = 3600;
7776

78-
const server = await serve(PORT, CACHE_DURATION);
77+
const server = await serve(PORT, DEFAULT_CACHE_DURATION);
7978
let driver, logInspector;
8079

8180
process.on("unhandledRejection", (err) => {

tests/server.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import "lws-log";
1010
import "lws-static";
1111

1212
const ROOT_DIR = path.join(process.cwd(), "./");
13+
export const DEFAULT_CACHE_DURATION = 3600;
1314

1415
class CacheControlPlugin {
1516
middleware(config) {
@@ -68,12 +69,12 @@ async function verifyStartup(ws, port) {
6869
function main() {
6970
const optionDefinitions = [
7071
{ name: "port", type: Number, defaultValue: 8080, description: "Set the test-server port, The default value is 8080." },
71-
{ name: "cache", type: Number, description: "Set the cache duration in seconds. If flag is present without a value, defaults to 3600." },
72+
{ name: "cache", type: Number, description: `Set the cache duration in seconds. If flag is present without a value, defaults to ${DEFAULT_CACHE_DURATION}.` },
7273
];
7374
const options = commandLineArgs(optionDefinitions);
7475
let cacheDuration = undefined;
7576
if ("cache" in options)
76-
cacheDuration = options.cache ?? 3600;
77+
cacheDuration = options.cache ?? DEFAULT_CACHE_DURATION;
7778

7879
serve(options.port, cacheDuration);
7980
}

0 commit comments

Comments
 (0)