Skip to content

Commit

Permalink
test:add test case for file server
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqingc committed May 22, 2019
1 parent 4f19439 commit eab8ebf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions http/file_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ async function serveDir(
// dirname has no prefix
const listEntry: string[] = [];
const fileInfos = await readDir(dirPath);
dirPath = dirPath.replace(currentDir, "");
for (const info of fileInfos) {
let fn = dirPath + "/" + info.name;
if (info.name === "index.html" && info.isFile()) {
Expand All @@ -163,7 +162,7 @@ async function serveDir(
listEntry.push(
createDirEntryDisplay(
info.name,
fn,
fn.replace(currentDir, ""),
info.isFile() ? info.len : null,
mode,
info.isDirectory()
Expand Down
6 changes: 6 additions & 0 deletions http/file_server_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ test(async function serveDirectory(): Promise<void> {
assert(res.headers.has("access-control-allow-headers"));
const page = await res.text();
assert(page.includes("azure-pipelines.yml"));
assert(/<td class="mode">\([a-zA-Z-]{10}\)<\/td>/.test(page));
assert(
page.includes(
`<td><a href="/azure-pipelines.yml">azure-pipelines.yml</a></td>`
)
);
} finally {
killFileServer();
}
Expand Down

0 comments on commit eab8ebf

Please sign in to comment.