From 3172759ca0319f5df72a809dac1e8cea72e02a51 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Oct 2021 15:59:57 +0300 Subject: [PATCH] chore(cloudcmd) lint --- client/dom/dom-tree.spec.js | 2 ++ common/datetime.spec.js | 1 + server/config.spec.js | 1 + server/rest/index.spec.js | 1 + server/validate.spec.js | 2 ++ static/user-menu.spec.js | 3 +++ 6 files changed, 10 insertions(+) diff --git a/client/dom/dom-tree.spec.js b/client/dom/dom-tree.spec.js index c59239ae..5c3e9a97 100644 --- a/client/dom/dom-tree.spec.js +++ b/client/dom/dom-tree.spec.js @@ -8,12 +8,14 @@ const {isContainClass} = require('./dom-tree'); test('dom: isContainClass: no element', (t) => { const [e] = tryCatch(isContainClass); + t.equal(e.message, 'element could not be empty!', 'should throw when no element'); t.end(); }); test('dom: isContainClass: no className', (t) => { const [e] = tryCatch(isContainClass, {}); + t.equal(e.message, 'className could not be empty!', 'should throw when no element'); t.end(); }); diff --git a/common/datetime.spec.js b/common/datetime.spec.js index 2919c87e..2d8f529e 100644 --- a/common/datetime.spec.js +++ b/common/datetime.spec.js @@ -31,6 +31,7 @@ test('common: datetime: no arg', (t) => { datetime(); global.Date = Date; + t.ok(called, 'should call new Date'); t.end(); }); diff --git a/server/config.spec.js b/server/config.spec.js index a9c6ad69..dbd85277 100644 --- a/server/config.spec.js +++ b/server/config.spec.js @@ -102,6 +102,7 @@ test('config: middle: no', (t) => { }; middle(req, res, next); + t.ok(next.calledWith(), 'should call next'); t.end(); }); diff --git a/server/rest/index.spec.js b/server/rest/index.spec.js index bd0c9645..22ffd4ad 100644 --- a/server/rest/index.spec.js +++ b/server/rest/index.spec.js @@ -50,6 +50,7 @@ test('rest: isRootAll', (t) => { test('rest: onPUT: no args', async (t) => { const [e] = await tryToCatch(_onPUT, {}); + t.equal(e.message, 'name should be a string!', 'should throw when no args'); t.end(); }); diff --git a/server/validate.spec.js b/server/validate.spec.js index 595b47b5..29cf23e4 100644 --- a/server/validate.spec.js +++ b/server/validate.spec.js @@ -24,6 +24,7 @@ test('validate: root: bad', (t) => { }; const [e] = tryCatch(cloudcmd, {config}); + t.equal(e.message, 'dir should be a string', 'should throw'); t.end(); }); @@ -64,6 +65,7 @@ test('validate: root: stat', (t) => { fs.statSync = statSync; mockRequire.stop(exitPath); + t.calledWith(fn, [msg, error], 'should call fn'); t.end(); }); diff --git a/static/user-menu.spec.js b/static/user-menu.spec.js index a1b196a0..8382904b 100644 --- a/static/user-menu.spec.js +++ b/static/user-menu.spec.js @@ -41,6 +41,7 @@ test('cloudcmd: static: user menu: IO.write', async (t) => { }); const path = '/.cloudcmd.menu.js'; + t.calledWith(write, [path, _data], 'should call IO.write'); t.end(); }); @@ -72,6 +73,7 @@ test('cloudcmd: static: user menu: setCurrentByName', async (t) => { }); const fileName = '.cloudcmd.menu.js'; + t.calledWith(setCurrentByName, [fileName], 'should call DOM.setCurrentByName'); t.end(); }); @@ -120,6 +122,7 @@ test('cloudcmd: static: user menu: compare directories', async (t) => { }); const {files} = DOM.CurrentInfo.files; + t.calledWith(DOM.getFilenames, [files], 'should call getFilenames'); t.end(); });