From 60310e5a837779b80a898cd5b862164d1e12d793 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Mon, 12 Aug 2024 17:09:52 -0300 Subject: [PATCH] test: nodeInfoCache fetch --- src/utils/domains.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/utils/domains.test.ts diff --git a/src/utils/domains.test.ts b/src/utils/domains.test.ts new file mode 100644 index 00000000..19ab4a83 --- /dev/null +++ b/src/utils/domains.test.ts @@ -0,0 +1,27 @@ +import { nodeInfoCache } from '@/utils/domains.ts'; +import { assert, assertObjectMatch } from '@std/assert'; + +Deno.test('NodeInfo request in gleasonator.dev', { sanitizeResources: false }, async () => { + const result = await nodeInfoCache.fetch('gleasonator.dev', { + signal: AbortSignal.timeout(5000), + }); + + assertObjectMatch(result, { + usage: { + users: {}, + }, + }); + + assert( + 'total' in result.usage.users && + typeof result.usage.users.total === 'number', + ); + assert( + 'activeMonth' in result.usage.users && + typeof result.usage.users.activeMonth === 'number', + ); + assert( + 'activeHalfyear' in result.usage.users && + typeof result.usage.users.activeHalfyear === 'number', + ); +});