mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-24 02:13:43 +03:00
Add more kitchen tests and minor fixes
This commit is contained in:
parent
1feca9b31d
commit
8b110e6176
|
@ -106,11 +106,12 @@
|
|||
|
||||
const oldMods = kitchenState(modsKey);
|
||||
if (oldMods) {
|
||||
// No migration!
|
||||
return oldMods;
|
||||
}
|
||||
|
||||
// In case of migration or first install.
|
||||
const [err, mods, ...warns] = createPacModifiers( kitchenState(modsKey) );
|
||||
// In case of first install.
|
||||
const [err, mods, ...warns] = createPacModifiers();
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
@ -154,7 +155,6 @@
|
|||
|
||||
});
|
||||
|
||||
console.log('Input mods:', mods);
|
||||
const self = {};
|
||||
Object.assign(self, getDefaults(), mods);
|
||||
self.ifNoMods = ifNoMods;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
const Chrome = require('sinon-chrome');
|
||||
const Storage = require('_project-root/tools/sinon-storage');
|
||||
const Chai = require('chai');
|
||||
const Mocha = require('mocha');
|
||||
|
@ -9,25 +8,67 @@ const CachelessRequire = require('_project-root/tools/cacheless-require')(module
|
|||
|
||||
Mocha.describe('window.apis.pacKitchen', function () {
|
||||
|
||||
|
||||
Mocha.beforeEach(function() {
|
||||
|
||||
global.chrome = Chrome;
|
||||
global.chrome = CachelessRequire('sinon-chrome/extensions');
|
||||
global.window = {
|
||||
chrome: Chrome,
|
||||
chrome: global.chrome,
|
||||
localStorage: new Storage(),
|
||||
};
|
||||
CachelessRequire('../00-init-apis.js');
|
||||
|
||||
});
|
||||
|
||||
Mocha.it('is evaluated and defined', function () {
|
||||
Mocha.it('is exported with correct default values', function () {
|
||||
|
||||
CachelessRequire('../35-pac-kitchen-api.js');
|
||||
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;
|
||||
Chai.expect(
|
||||
mods, 'to expose default configs on first run'
|
||||
).to.exist;
|
||||
Chai.expect(mods.ifNoMods, 'to impose modifications by default (prohibits DIRECT)').to.be.false;
|
||||
|
||||
const orderedMods = window.apis.pacKitchen.getOrderedConfigs();
|
||||
Chai.expect(orderedMods, 'to have method for getting ordered configs').to.exist;
|
||||
{
|
||||
const several = 9;
|
||||
Chai.expect(orderedMods.length, 'to have several ordered configs').to.be.above(several);
|
||||
}
|
||||
|
||||
Chai.expect(
|
||||
Object.keys(mods).length,
|
||||
'pacModifiers to inherit default configs keys as props and add extra props'
|
||||
).to.be.above(orderedMods.length);
|
||||
|
||||
Chai.expect(
|
||||
orderedMods.every((mod) => mods[mod.key] === mod.dflt),
|
||||
'all configs to be default on first run'
|
||||
).to.be.ok;
|
||||
|
||||
const excMods = window.apis.pacKitchen.getOrderedConfigs('exceptions');
|
||||
Chai.expect(excMods.length, 'to have several ordered mods under category "exceptions"').to.be.above(0);
|
||||
|
||||
const proxyMods = window.apis.pacKitchen.getOrderedConfigs('ownProxies');
|
||||
Chai.expect(proxyMods.length, 'to have several ordered mods under category "ownProxies"').to.be.above(0);
|
||||
|
||||
const generalMods = window.apis.pacKitchen.getOrderedConfigs('general');
|
||||
Chai.expect(generalMods.length, 'to have several ordered mods without category').to.be.above(0);
|
||||
|
||||
Chai.expect(
|
||||
orderedMods.length, 'to be a sum of categorized (and ordered) mods'
|
||||
).to.be.equal(
|
||||
proxyMods.length + excMods.length + generalMods.length
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
Mocha.it('is installed (by modifying `chrome.proxy.settings.set`)', function () {
|
||||
|
||||
CachelessRequire('../35-pac-kitchen-api.js');
|
||||
Chai.expect(originalSet.notCalled, 'original set not to be called during install').to.be.true;
|
||||
//Chai.expect(originalSet, 'settings.set to be modified').not.to.be.equal(window.chrome.proxy.settings.set);
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ Mocha.describe('window.utils', function () {
|
|||
|
||||
});
|
||||
|
||||
Mocha.it('exports as global', function () {
|
||||
Mocha.it('is exported as global', function () {
|
||||
|
||||
CachelessRequire(initApis);
|
||||
Chai.expect(window.utils, 'to be exported as global').to.exist;
|
||||
|
|
Loading…
Reference in New Issue
Block a user