mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(markdown) coverage
This commit is contained in:
parent
dd256a9252
commit
ad380bb233
3 changed files with 31 additions and 0 deletions
1
test/server/fixture/markdown.html
Normal file
1
test/server/fixture/markdown.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<h1>hello</h1>
|
||||
1
test/server/fixture/markdown.md
Normal file
1
test/server/fixture/markdown.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
# hello
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue