From 3bc7642dcfeaa1a298b3678c749b43a5683765ad Mon Sep 17 00:00:00 2001 From: siaeyy Date: Wed, 15 Jan 2025 05:27:52 +0300 Subject: [PATCH] test(ext/dns): Test for dns resolving --- tests/unit/dns_test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/unit/dns_test.ts diff --git a/tests/unit/dns_test.ts b/tests/unit/dns_test.ts new file mode 100644 index 0000000000..98367dc9c2 --- /dev/null +++ b/tests/unit/dns_test.ts @@ -0,0 +1,24 @@ +// Copyright 2018-2025 the Deno authors. MIT license. + +import { resolve4, resolve6 } from "node:dns/promises"; +import { assertEquals } from "@std/assert/equals"; + +Deno.test({ + name: "Dns resolving for ttl values, A and AAAA records", + async fn() { + const ARecord = "34.120.54.55"; + const AAAARecord = "2600:1901::6d85::"; + + const ARes1 = await Deno.resolveDns("deno.com", "A", { ttl: true }); + const ARes2 = await resolve4("deno.com", { ttl: true }); + + assertEquals(ARes1[0].data, ARecord); + assertEquals(ARes2[0].address, ARecord); + + const AAAARes1 = await Deno.resolveDns("deno.com", "AAAA", { ttl: true }); + const AAAARes2 = await resolve6("deno.com", { ttl: true }); + + assertEquals(AAAARes1[0].data, AAAARecord); + assertEquals(AAAARes2[0].address, AAAARecord); + }, +});