test: nodeInfoCache fetch

This commit is contained in:
P. Reis 2024-08-12 17:09:52 -03:00
parent b3ef9b5e01
commit 60310e5a83

27
src/utils/domains.test.ts Normal file
View file

@ -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',
);
});