From c8d2098e5b4d648465cb74ff92798df695fd73bf Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 19 Aug 2020 18:12:30 +0300 Subject: [PATCH] test(storage) coverage --- client/dom/storage.spec.js | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/client/dom/storage.spec.js b/client/dom/storage.spec.js index 3922a616..0e50bd4d 100644 --- a/client/dom/storage.spec.js +++ b/client/dom/storage.spec.js @@ -73,3 +73,56 @@ test('cloudcmd: client: storage: setJson', async (t) => { t.ok(setItem.calledWith('hello', expected)); t.end(); }); + +test('cloudcmd: client: storage: remove', async (t) => { + const {localStorage} = global; + const removeItem = stub(); + + global.localStorage = { + removeItem, + }; + + await storage.remove('hello'); + global.localStorage = localStorage; + + t.ok(removeItem.calledWith('hello'), 'should call removeItem'); + t.end(); +}); + +test('cloudcmd: client: storage: clear', async (t) => { + const {localStorage} = global; + const clear = stub(); + + global.localStorage = { + clear, + }; + + await storage.clear(); + global.localStorage = localStorage; + + t.ok(clear.calledWith(), 'should call clear'); + t.end(); +}); + +test('cloudcmd: client: storage: removeMatch', async (t) => { + const {localStorage} = global; + const removeItem = stub(); + + global.localStorage = { + removeItem, + fileA: 1, + fileB: 2, + }; + + await storage.removeMatch('file'); + global.localStorage = localStorage; + const {args} = removeItem; + const expected = [ + ['fileA'], + ['fileB'], + ]; + + t.deepEqual(args, expected); + t.end(); +}); +