Skip to content

Commit

Permalink
test improved.
Browse files Browse the repository at this point in the history
  • Loading branch information
dojyorin committed Jan 30, 2024
1 parent 2d95952 commit e539dfe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
5 changes: 4 additions & 1 deletion deps.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export {assertEquals} from "https://deno.land/[email protected]/assert/mod.ts";
export {dirname, fromFileUrl} from "https://deno.land/[email protected]/path/mod.ts";
export {exists} from "https://deno.land/[email protected]/fs/mod.ts";
export {delay} from "https://deno.land/[email protected]/async/mod.ts";

export {DOMParser} from "https://deno.land/x/[email protected]/deno-dom-wasm.ts";
export {DOMParser} from "https://deno.land/x/[email protected]/deno-dom-wasm.ts";

export {init as smtpTest} from "npm:[email protected]";
35 changes: 24 additions & 11 deletions test/deno_ext/smtp.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import {assertEquals} from "../../deps.test.ts";
import {smtpSend} from "../../src/deno_ext/smtp.ts";
import {assertEquals, delay, smtpTest} from "../../deps.test.ts";
import {type MailMessage, smtpSend} from "../../src/deno_ext/smtp.ts";

const cs = "";
const em = "";
const sample:MailMessage = {
from: "[email protected]",
to: ["[email protected]"],
title: "Test title",
body: "Test body"
};

Deno.test({
ignore: true,
name: "SMTP: Send",
async fn(){
await smtpSend(cs, {
from: em,
to: [em],
title: "CI Test",
body: "CI Test"
const server = smtpTest(10025);
const result = new Promise<MailMessage>((res)=>{
server.bind((_, __, {headers, body})=>{
res({
from: <string>headers.from,
to: [<string>headers.to],
title: <string>headers.subject,
body: body ?? ""
});
});
});

assertEquals(true, true);
await smtpSend("smtp://127.0.0.1:10025", sample);
await new Promise<void>(done => server.stop(done));

assertEquals(await result, sample);

await delay(1000);
}
});
4 changes: 2 additions & 2 deletions test/pure/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Deno.test({
async fn(){
const server = Deno.serve({
hostname: "127.0.0.1",
port: 62000,
port: 10080,
}, () => new Response(sample));

const result = await fetchExtend("http://127.0.0.1:62000", "byte");
const result = await fetchExtend("http://127.0.0.1:10080", "byte");
await server.shutdown();

assertEquals(result, sample);
Expand Down

0 comments on commit e539dfe

Please sign in to comment.