From bb9dde869e225a9321cdf94825cb600da5ae9617 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 8 Nov 2018 19:13:10 +0200 Subject: [PATCH] test(fs) serve-once --- package.json | 1 + test/rest/fs.js | 33 ++++++++++----------------------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 441f0103..91532e73 100644 --- a/package.json +++ b/package.json @@ -217,6 +217,7 @@ "supermenu": "^2.1.2", "tape": "^4.4.0", "tar-stream": "^1.5.2", + "try-to-tape": "^1.0.0", "unionfs": "^3.0.2", "url-loader": "^1.0.1", "version-io": "^2.0.1", diff --git a/test/rest/fs.js b/test/rest/fs.js index 08c599df..9247ea4f 100644 --- a/test/rest/fs.js +++ b/test/rest/fs.js @@ -1,29 +1,16 @@ 'use strict'; -const test = require('tape'); -const {promisify} = require('es6-promisify'); -const pullout = require('pullout'); -const request = require('request'); -const before = require('../before'); +const tryToTape = require('try-to-tape'); +const test = tryToTape(require('tape')); -const warp = (fn, ...a) => (...b) => fn(...b, ...a); -const _pullout = promisify(pullout); +const cloudcmd = require('../..'); +const {request} = require('serve-once')(cloudcmd); -const get = promisify((url, fn) => { - fn(null, request(url)); -}); - -test('cloudcmd: rest: fs: path', (t) => { - before((port, after) => { - get(`http://localhost:${port}/api/v1/fs`) - .then(warp(_pullout, 'string')) - .then(JSON.parse) - .then((dir) => { - t.equal('/', dir.path, 'should dir path be "/"'); - t.end(); - after(); - }) - .catch(console.error); - }); +test('cloudcmd: rest: fs: path', async (t) => { + const {body} = await request.get(`/api/v1/fs`); + const {path} = JSON.parse(body); + + t.equal('/', path, 'should dir path be "/"'); + t.end(); });