zz_

test.js

thoward37@gmail.com/push-test2-1791933121043 / test.js @ 4264911f Download
Ladder Summary
  • file This file is an AVA test suite that imports the `isUp` function from `./index.js` and verifies its behavior with three cases: confirming a reachable URL returns `true`, confirming a randomly‑generated nonexistent URL returns `false`, and asserting that calling `isUp` with an invalid URL string throws an error with the message “Invalid URL”. The file itself does not export any functions or classes.
 import test from 'ava';
-import fn from './';
+import uniqueString from 'unique-string';
+import isUp from '.';
 
 test('up', async t => {
- t.true(await fn('google.com'));
+ t.true(await isUp('https://google.com'));
 });
 
 test('down', async t => {
- t.false(await fn(`foobar${Math.random().toString().slice(2)}.com`));
+ t.false(await isUp(`https://foobar${uniqueString()}.com`));
 });
 
 test('invalid domain', async t => {
- try {
- await fn('hi');
- t.fail('Should throw error');
- } catch (err) {
- t.is(err.message, 'Invalid domain');
- }
+ await t.throwsAsync(isUp('unicorn'), 'Invalid domain');
 });