test(markdown) coverage

This commit is contained in:
coderaiser 2017-08-17 11:38:32 +03:00
parent dd256a9252
commit ad380bb233
3 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1 @@
<h1>hello</h1>

View file

@ -0,0 +1 @@
# hello

View file

@ -1,5 +1,7 @@
'use strict';
const fs = require('fs');
const path = require('path');
const test = require('tape');
const promisify = require('es6-promisify');
const pullout = require('pullout');
@ -46,6 +48,33 @@ test('cloudcmd: markdown: relative', (t) => {
});
});
test('cloudcmd: markdown: put', (t) => {
const dir = path.join(__dirname, 'fixture');
const md = path.join(dir, 'markdown.md');
const html = path.join(dir, 'markdown.html');
const mdStream = fs.createReadStream(md);
const htmlFile = fs.readFileSync(html, 'utf8');
before((port, after) => {
const url = `http://localhost:${port}/api/v1/markdown`;
const putStream = mdStream
.pipe(request.put(url));
_pullout(putStream, 'string')
.then((result) => {
t.equal(result, htmlFile, 'should render markdown input to html');
t.end();
after();
})
.catch((error) => {
t.fail(error.message);
t.end();
});
});
});
test('cloudcmd: markdown: no name', (t) => {
t.throws(markdown, /name should be string!/, 'should throw when no name');
t.end();