Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test improved. #90

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading