Skip to content

Instantly share code, notes, and snippets.

@outsideris
Created August 14, 2018 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save outsideris/ed59fc0fa0503de691fcd3a7b822e5e1 to your computer and use it in GitHub Desktop.
Save outsideris/ed59fc0fa0503de691fcd3a7b822e5e1 to your computer and use it in GitHub Desktop.
moca test
const { test } = require('./util');
describe('node', () => {
it('should something', async () => {
const expected = {
address: 'GB73FN4YLGQQ3ISDCLZGJDPZKUYF3KZGAPBIWDDEMTJXQDNP7WZ5J3RL',
alias: 'GB73.7WZ5',
state: 'NONE',
validators: {
GACYJM6DQVNLYI53IUIOC7MEKFUT2DFMFVWL4R6IPDNRG3ZKICIAFUHO: {
address: 'GACYJM6DQVNLYI53IUIOC7MEKFUT2DFMFVWL4R6IPDNRG3ZKICIAFUHO',
alias: 'GACY.ICIA',
endpoint: 'https://localhost:12346',
state: 'NONE'
},
GDAXGCPCWAGWJZXUIWKAYZUMCRPLGX3XSCQY7CE6HNGOA34EGJFJU6PK: {
address: 'GDAXGCPCWAGWJZXUIWKAYZUMCRPLGX3XSCQY7CE6HNGOA34EGJFJU6PK',
alias: 'GDAX.GJFJ',
endpoint: 'https://localhost:12347',
state: 'NONE'
}
}
};
await test('https://localhost:12345/node/', expected, 200)
});
});
{
"name": "sebak-e2e",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "NODE_TLS_REJECT_UNAUTHORIZED=0 mocha"
},
"author": "",
"license": "ISC",
"devDependencies": {
"got": "^9.0.0",
"mocha": "^5.2.0",
"unexpected": "^10.38.0"
}
}
const expect = require('unexpected');
const got = require('got');
module.exports = {
test: async (targetUrl, expected, statusCode) => {
const res = await got(targetUrl);
expect(JSON.parse(res.body), 'to satisfy', expected)
if (statusCode) {
expect(res.statusCode, 'to be', statusCode)
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment