test(markdown) coverage: put: error

This commit is contained in:
coderaiser 2017-08-17 13:12:10 +03:00
parent ad380bb233
commit 6dba4ba186

View file

@ -13,6 +13,7 @@ const before = require('../before');
const warp = (fn, ...a) => (...b) => fn(...b, ...a);
const _pullout = promisify(pullout);
const _markdown = promisify(markdown);
const get = promisify((url, fn) => {
fn(null, request(url));
@ -75,6 +76,27 @@ test('cloudcmd: markdown: put', (t) => {
});
});
test('cloudcmd: markdown: put: error', (t) => {
const dir = path.join(__dirname, 'fixture');
const md = path.join(dir, 'markdown-not-exist.md');
const name = 'hello';
const mdStream = fs.createReadStream(md);
mdStream.url = 'http://hello.world';
mdStream.method = 'PUT';
_markdown(name, mdStream)
.then((result) => {
t.fail(`should fail but: ${result}`);
t.end();
})
.catch((error) => {
t.ok(error.message.includes('ENOENT: no such file or directory'), 'should emit error');
t.end();
});
});
test('cloudcmd: markdown: no name', (t) => {
t.throws(markdown, /name should be string!/, 'should throw when no name');
t.end();