From 14dcd69a1dbc8ca8bded7100c6cd3ec14f736912 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 8 Jan 2017 20:03:46 +0200 Subject: [PATCH] fix(markdown) DIR_ROOT: help --- server/markdown.js | 2 +- test/server/markdown.js | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/server/markdown.js diff --git a/server/markdown.js b/server/markdown.js index 9ff4f111..8e6538c3 100644 --- a/server/markdown.js +++ b/server/markdown.js @@ -1,6 +1,6 @@ 'use strict'; -const DIR_ROOT = __dirname + '/../../'; +const DIR_ROOT = __dirname + '/../'; const fs = require('fs'); const pullout = require('pullout/legacy'); diff --git a/test/server/markdown.js b/test/server/markdown.js new file mode 100644 index 00000000..17760792 --- /dev/null +++ b/test/server/markdown.js @@ -0,0 +1,46 @@ +'use strict'; + +const test = require('tape'); +const promisify = require('es6-promisify'); +const pullout = require('pullout'); +const request = require('request'); + +const before = require('../before'); + +const warp = (fn, ...a) => (...b) => fn(...b, ...a); +const _pullout = promisify(pullout); + +const get = promisify((url, fn) => { + fn(null, request(url)); +}); + +test('cloudcmd: markdown: relative: error', (t) => { + before((port, after) => { + get(`http://localhost:${port}/api/v1/markdown/not-found?relative`) + .then(warp(_pullout, 'string')) + .then((result) => { + t.ok(/ENOENT/.test(result), 'should not found'); + t.end(); + after(); + }) + .catch((error) => { + console.log(error); + }); + }); +}); + +test('cloudcmd: markdown: relative', (t) => { + before((port, after) => { + get(`http://localhost:${port}/api/v1/markdown/HELP.md?relative`) + .then(warp(_pullout, 'string')) + .then((result) => { + t.notOk(/ENOENT/.test(result), 'should not return error'); + t.end(); + after(); + }) + .catch((error) => { + console.log(error); + }); + }); +}); +