Skip to content

Instantly share code, notes, and snippets.

@mk-pmb
Last active September 28, 2018 14:38
Show Gist options
  • Select an option

  • Save mk-pmb/5be4e38b95dce39ca0f22d50f43bd357 to your computer and use it in GitHub Desktop.

Select an option

Save mk-pmb/5be4e38b95dce39ca0f22d50f43bd357 to your computer and use it in GitHub Desktop.
#!/usr/bin/env nodemjs
// -*- coding: utf-8, tab-width: 2 -*-
import test from 'p-tape';
import 'p-fatal';
import pDelay from 'promise-delay';
function stubAsyncDataSource(x) { return pDelay(200, x); }
test('Import package meta', async (t) => {
t.plan(3);
let meta;
await t.test('can read', async (sub) => {
sub.plan(1);
meta = (await import('../package.json')).default;
sub.equal((meta && typeof meta), 'object');
});
await t.test('homepage alive', async (sub) => {
sub.plan(2);
const webRequest = await stubAsyncDataSource(meta.homepage);
sub.equal(webRequest.httpStatus, 200);
sub.equal(webRequest.title, meta.name);
});
await t.test('has no bugs', async (sub) => {
sub.plan(2);
const webRequest = await stubAsyncDataSource(meta.bugs.url);
sub.equal(webRequest.httpStatus, 200);
sub.equal(webRequest.meta.nBugs, 0);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment