From d98156faed4b2f0fc700ad4ab989e8c4ad8463fe Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 11 Jul 2017 13:56:11 +0300 Subject: [PATCH] test(terminal) coverage --- package.json | 3 ++- test/server/terminal.js | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2042ea10..88cd73ea 100644 --- a/package.json +++ b/package.json @@ -179,6 +179,7 @@ "jshint": "^2.8.0", "minor": "^1.2.2", "mkdirp": "^0.5.1", + "mock-require": "^2.0.2", "morgan": "^1.6.1", "nodemon": "^1.9.1", "nsp": "^2.2.1", @@ -207,4 +208,4 @@ }, "license": "MIT", "main": "legacy/server/cloudcmd.js" -} \ No newline at end of file +} diff --git a/test/server/terminal.js b/test/server/terminal.js index 777fcefd..13dac032 100644 --- a/test/server/terminal.js +++ b/test/server/terminal.js @@ -1,6 +1,7 @@ 'use strict'; const test = require('tape'); +const mock = require('mock-require'); const diff = require('sinon-called-with-diff'); const sinon = diff(require('sinon')); @@ -58,6 +59,31 @@ test('cloudcmd: terminal: enabled', (t) => { console.log = log; clean(configPath); + require(configPath); + + t.end(); +}); + +test('cloudcmd: terminal: no arg', (t) => { + const gritty = {}; + + mock('gritty', gritty); + + clean(terminalPath); + stub(configPath, (a) => { + if (a === 'terminal') + return true; + + return 'gritty'; + }); + + const terminal = require(terminalPath); + const result = terminal(); + + t.equal(result, gritty, 'should equal'); + + clean(configPath); + require(configPath); t.end(); });