From accdcc885d575cc5d64979a113342b1301e23bbd Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 31 May 2018 13:54:28 +0300 Subject: [PATCH] test(cloudcmd) sw --- test/server/cloudcmd.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/server/cloudcmd.js b/test/server/cloudcmd.js index bc304c49..102eb268 100644 --- a/test/server/cloudcmd.js +++ b/test/server/cloudcmd.js @@ -7,18 +7,24 @@ const diff = require('sinon-called-with-diff'); const sinon = diff(require('sinon')); const currify = require('currify'); const clean = require('clear-module'); +const request = require('request'); +const {promisify} = require('es6-promisify'); const DIR = '../../server/'; const cloudcmdPath = DIR + 'cloudcmd'; +const beforePath = '../before'; -const cloudcmd = require(cloudcmdPath); const config = require(DIR + 'config'); +const cloudcmd = require(cloudcmdPath); +const {connect} = require(beforePath); const { _getPrefix, _auth, _replacePrefix, } = cloudcmd; +const get = promisify(request); + test('cloudcmd: args: no', (t) => { const fn = () => cloudcmd(); @@ -219,6 +225,16 @@ test('cloudcmd: getIndexPath: development', (t) => { t.end(); }); +test('cloudcmd: sw', async (t) => { + const {port, done} = await connect(); + const {statusCode}= await get(`http://localhost:${port}/sw.js`); + done(); + + t.equal(statusCode, 200, 'should return sw'); + + t.end(); +}); + function cleanNodeEnv() { const {NODE_ENV} = process.env; process.env.NODE_ENV = '';