From ad380bb2338a20d21218eda0a1427d147cc0f616 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 17 Aug 2017 11:38:32 +0300 Subject: [PATCH] test(markdown) coverage --- test/server/fixture/markdown.html | 1 + test/server/fixture/markdown.md | 1 + test/server/markdown.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 test/server/fixture/markdown.html create mode 100644 test/server/fixture/markdown.md diff --git a/test/server/fixture/markdown.html b/test/server/fixture/markdown.html new file mode 100644 index 00000000..6e7c1e6a --- /dev/null +++ b/test/server/fixture/markdown.html @@ -0,0 +1 @@ +

hello

diff --git a/test/server/fixture/markdown.md b/test/server/fixture/markdown.md new file mode 100644 index 00000000..8954bb97 --- /dev/null +++ b/test/server/fixture/markdown.md @@ -0,0 +1 @@ +# hello diff --git a/test/server/markdown.js b/test/server/markdown.js index 780d548f..553494b6 100644 --- a/test/server/markdown.js +++ b/test/server/markdown.js @@ -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();