From ef116a9a53ab546634ad7bdb358aac73deee5e63 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 8 Nov 2018 22:34:26 +0200 Subject: [PATCH] test(rest) JSON.parse -> type: json --- test/rest/config.js | 7 ++++--- test/rest/fs.js | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/rest/config.js b/test/rest/config.js index e33a23a5..0d161e64 100644 --- a/test/rest/config.js +++ b/test/rest/config.js @@ -19,10 +19,11 @@ const manageConfig = require('../../server/config'); const pathConfig = path.join(os.homedir(), '.cloudcmd.json'); test('cloudcmd: rest: config: get', async (t) => { - const {body} = await request.get('/api/v1/config'); - const config = JSON.parse(body); + const {body} = await request.get('/api/v1/config', { + type: 'json' + }); - t.notOk(config.auth, 'should config.auth to be false'); + t.notOk(body.auth, 'should config.auth to be false'); t.end(); }); diff --git a/test/rest/fs.js b/test/rest/fs.js index 9247ea4f..c8010c49 100644 --- a/test/rest/fs.js +++ b/test/rest/fs.js @@ -7,8 +7,11 @@ const cloudcmd = require('../..'); const {request} = require('serve-once')(cloudcmd); test('cloudcmd: rest: fs: path', async (t) => { - const {body} = await request.get(`/api/v1/fs`); - const {path} = JSON.parse(body); + const {body} = await request.get(`/api/v1/fs`, { + type: 'json' + }); + + const {path} = body; t.equal('/', path, 'should dir path be "/"'); t.end();