test(markdown) coverage

This commit is contained in:
coderaiser 2017-08-16 14:23:53 +03:00
parent 56a833516d
commit 594d3770b2
2 changed files with 23 additions and 2 deletions

View file

@ -10,11 +10,11 @@ const markdown = require('markdown-it')();
const root = require('./root');
module.exports = (name, request, callback) => {
check(name, request, callback);
const method = request.method;
const query = ponse.getQuery(request);
check(name, request, callback);
switch(method) {
case 'GET':
name = name.replace('/markdown', '');

View file

@ -5,6 +5,8 @@ const promisify = require('es6-promisify');
const pullout = require('pullout');
const request = require('request');
const markdown = require('../../server/markdown');
const before = require('../before');
const warp = (fn, ...a) => (...b) => fn(...b, ...a);
@ -44,3 +46,22 @@ test('cloudcmd: markdown: relative', (t) => {
});
});
test('cloudcmd: markdown: no name', (t) => {
t.throws(markdown, /name should be string!/, 'should throw when no name');
t.end();
});
test('cloudcmd: markdown: no request', (t) => {
const fn = () => markdown('hello');
t.throws(fn, /request could not be empty!/, 'should throw when no request');
t.end();
});
test('cloudcmd: markdown: no function', (t) => {
const fn = () => markdown('hello', {});
t.throws(fn, /callback should be function!/, 'should throw when no callback');
t.end();
});