mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
test(markdown) coverage: put: error
This commit is contained in:
parent
ad380bb233
commit
6dba4ba186
1 changed files with 22 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue