From 1feca9b31d69ebe5fae32aea135510065569755d Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Fri, 5 May 2017 21:38:26 -0700 Subject: [PATCH] Change asserts to expects, add one more test --- .../src/extension-common/35-pac-kitchen-api.js | 7 +++++-- .../src/extension-common/test/pac-kitchen.js | 5 ++++- .../src/extension-common/test/utils.js | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js index 1500c33..1ee0e39 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/35-pac-kitchen-api.js @@ -104,9 +104,12 @@ const getCurrentConfigs = function getCurrentConfigs() { - return kitchenState(modsKey); + const oldMods = kitchenState(modsKey); + if (oldMods) { + return oldMods; + } - // In case of migration. + // In case of migration or first install. const [err, mods, ...warns] = createPacModifiers( kitchenState(modsKey) ); if (err) { throw err; diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/test/pac-kitchen.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/test/pac-kitchen.js index d62a678..5d286a5 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/test/pac-kitchen.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/test/pac-kitchen.js @@ -24,7 +24,10 @@ Mocha.describe('window.apis.pacKitchen', function () { Mocha.it('is evaluated and defined', function () { CachelessRequire('../35-pac-kitchen-api.js'); - Chai.assert.ok(window.apis.pacKitchen, 'exports to globals'); + Chai.expect(window.apis.pacKitchen, 'to be exported as global').to.exist; + + const mods = window.apis.pacKitchen.getPacMods(); + Chai.expect(mods, 'expose default configs on first run').to.exist; }); diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/test/utils.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/test/utils.js index bf2f9f1..ab37402 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/test/utils.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/test/utils.js @@ -18,8 +18,8 @@ Mocha.describe('window.utils', function () { Mocha.it('exports as global', function () { CachelessRequire(initApis); - Chai.assert.ok(window.utils, 'exported to globals'); - Chai.assert.isNotOk(window.apis.version.ifMini, 'is not MINI version'); + Chai.expect(window.utils, 'to be exported as global').to.exist; + Chai.expect(window.apis.version.ifMini, 'to be marked as not MINI version by default').to.be.false; });