mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 00:21:05 -05:00
test(std/mime): make tests runnable from any directory (#7398)
This commit is contained in:
parent
11afd071ae
commit
79b2510617
1 changed files with 7 additions and 5 deletions
|
@ -19,7 +19,9 @@ const e = new TextEncoder();
|
||||||
const boundary = "--abcde";
|
const boundary = "--abcde";
|
||||||
const dashBoundary = e.encode("--" + boundary);
|
const dashBoundary = e.encode("--" + boundary);
|
||||||
const nlDashBoundary = e.encode("\r\n--" + boundary);
|
const nlDashBoundary = e.encode("\r\n--" + boundary);
|
||||||
const testdataDir = path.resolve("mime", "testdata");
|
|
||||||
|
const moduleDir = path.dirname(path.fromFileUrl(import.meta.url));
|
||||||
|
const testdataDir = path.resolve(moduleDir, "testdata");
|
||||||
|
|
||||||
Deno.test("multipartScanUntilBoundary1", function (): void {
|
Deno.test("multipartScanUntilBoundary1", function (): void {
|
||||||
const data = `--${boundary}`;
|
const data = `--${boundary}`;
|
||||||
|
@ -92,7 +94,7 @@ Deno.test("multipartMultipartWriter", async function (): Promise<void> {
|
||||||
const mw = new MultipartWriter(buf);
|
const mw = new MultipartWriter(buf);
|
||||||
await mw.writeField("foo", "foo");
|
await mw.writeField("foo", "foo");
|
||||||
await mw.writeField("bar", "bar");
|
await mw.writeField("bar", "bar");
|
||||||
const f = await Deno.open(path.resolve("./mime/testdata/sample.txt"), {
|
const f = await Deno.open(path.join(testdataDir, "sample.txt"), {
|
||||||
read: true,
|
read: true,
|
||||||
});
|
});
|
||||||
await mw.writeFile("file", "sample.txt", f);
|
await mw.writeFile("file", "sample.txt", f);
|
||||||
|
@ -175,7 +177,7 @@ Deno.test("multipartMultipartWriter3", async function (): Promise<void> {
|
||||||
Deno.test({
|
Deno.test({
|
||||||
name: "[mime/multipart] readForm() basic",
|
name: "[mime/multipart] readForm() basic",
|
||||||
async fn() {
|
async fn() {
|
||||||
const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
|
const o = await Deno.open(path.join(testdataDir, "sample.txt"));
|
||||||
const mr = new MultipartReader(
|
const mr = new MultipartReader(
|
||||||
o,
|
o,
|
||||||
"--------------------------434049563556637648550474",
|
"--------------------------434049563556637648550474",
|
||||||
|
@ -247,7 +249,7 @@ Deno.test({
|
||||||
Deno.test({
|
Deno.test({
|
||||||
name: "[mime/multipart] removeAll() should remove all tempfiles",
|
name: "[mime/multipart] removeAll() should remove all tempfiles",
|
||||||
async fn() {
|
async fn() {
|
||||||
const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
|
const o = await Deno.open(path.join(testdataDir, "sample.txt"));
|
||||||
const mr = new MultipartReader(
|
const mr = new MultipartReader(
|
||||||
o,
|
o,
|
||||||
"--------------------------434049563556637648550474",
|
"--------------------------434049563556637648550474",
|
||||||
|
@ -274,7 +276,7 @@ Deno.test({
|
||||||
Deno.test({
|
Deno.test({
|
||||||
name: "[mime/multipart] entries()",
|
name: "[mime/multipart] entries()",
|
||||||
async fn() {
|
async fn() {
|
||||||
const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
|
const o = await Deno.open(path.join(testdataDir, "sample.txt"));
|
||||||
const mr = new MultipartReader(
|
const mr = new MultipartReader(
|
||||||
o,
|
o,
|
||||||
"--------------------------434049563556637648550474",
|
"--------------------------434049563556637648550474",
|
||||||
|
|
Loading…
Reference in a new issue