Added tests for Toggles

This commit is contained in:
Daniël van Noord
2021-04-13 15:59:37 +02:00
parent d23719c2a8
commit e4cdc6b85a
16 changed files with 309 additions and 160 deletions

View File

@@ -1,6 +1,6 @@
import { before, beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import { l, Game } from '../../GlobalsForTesting'; // eslint-disable-line no-unused-vars
import { l, Game } from '../../GlobalsForTesting';
import ToggleBotBar from '../../../src/Config/Toggles/ToggleBotBar';
import { CMOptions } from '../../../src/Config/VariablesAndData';

View File

@@ -0,0 +1,33 @@
import { before, beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import { Game } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleDetailedTime from '../../../src/Config/Toggles/ToggleDetailedTime';
import { BackupFunctions } from '../../../src/Main/VariablesAndData';
describe('ToggleDetailedTime', function () {
global.Game = Game;
beforeEach(function () {
ToggleDetailedTime();
});
describe('DetailedTime = 0', function () {
before(function () {
CMOptions.DetailedTime = 0;
BackupFunctions.sayTime = 'BackupFunctions.sayTime';
});
it('Set correct time function', function () {
assert.equal(Game.sayTime, 'BackupFunctions.sayTime');
});
});
describe('DetailedTime = 1', function () {
before(function () {
CMOptions.DetailedTime = 1;
});
it('Set correct time function', function () {
assert.equal(Game.sayTime.name, 'CMSayTime');
});
});
});

View File

@@ -0,0 +1,17 @@
import { beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import ToggleFavouriteSetting from '../../../src/Config/Toggles/ToggleFavourites';
import { FavouriteSettings } from '../../../src/Disp/VariablesAndData';
describe('ToggleFavouriteSetting', function () {
beforeEach(function () {
global.domids = {};
});
// TODO: Can't write test for checking existing config due to Babel/Typescript problem
it('New config', function () {
FavouriteSettings.push('TestConfig');
ToggleFavouriteSetting('TestConfig2');
assert.deepEqual(FavouriteSettings, ['TestConfig', 'TestConfig2']);
});
});

View File

@@ -0,0 +1,46 @@
import { before, beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import { l } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleGCTimer from '../../../src/Config/Toggles/ToggleGCTimer';
import { GCTimers } from '../../../src/Disp/VariablesAndData';
import { CacheGoldenShimmersByID } from '../../../src/Cache/VariablesAndData';
describe('ToggleGCTimer', function () {
global.l = l;
beforeEach(function () {
global.domids = {};
GCTimers[0] = { style: {} };
GCTimers[1] = { style: {} };
CacheGoldenShimmersByID[0] = {
l: { style: { left: 'Test00', top: 'Test01' } },
};
CacheGoldenShimmersByID[1] = {
l: { style: { left: 'Test10', top: 'Test11' } },
};
ToggleGCTimer();
});
describe('GCTimer = 0', function () {
before(function () {
CMOptions.GCTimer = 0;
});
it('Toggle style correctly', function () {
assert.equal(GCTimers[0].style.display, 'none');
assert.equal(GCTimers[1].style.display, 'none');
});
});
describe('GCTimer = 1', function () {
before(function () {
CMOptions.GCTimer = 1;
});
it('Toggle style correctly', function () {
assert.equal(GCTimers[0].style.display, 'block');
assert.equal(GCTimers[0].style.left, 'Test00');
assert.equal(GCTimers[0].style.top, 'Test01');
assert.equal(GCTimers[1].style.display, 'block');
});
});
});

View File

@@ -0,0 +1,32 @@
import { before, beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import { l } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleSectionHideButtons from '../../../src/Config/Toggles/ToggleSectionHideButtons';
describe('ToggleSectionHideButtons', function () {
global.l = l;
beforeEach(function () {
global.domids = {};
ToggleSectionHideButtons();
});
describe('HideSectionsButtons = 0', function () {
before(function () {
CMOptions.HideSectionsButtons = 0;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMSectionHidButtons.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('HideSectionsButtons = 1', function () {
before(function () {
CMOptions.HideSectionsButtons = 1;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMSectionHidButtons.style.display, ''); // eslint-disable-line no-undef
});
});
});

View File

@@ -0,0 +1,36 @@
import { before, beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import { l } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleToolWarnPos from '../../../src/Config/Toggles/ToggleToolWarnPos';
describe('ToggleToolWarnPos', function () {
global.l = l;
beforeEach(function () {
global.domids = {};
ToggleToolWarnPos();
});
describe('ToolWarnPos = 0', function () {
before(function () {
CMOptions.ToolWarnPos = 0;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMDispTooltipWarningParent.style.top, 'auto'); // eslint-disable-line no-undef
assert.equal(domids.CMDispTooltipWarningParent.style.margin, '4px -4px'); // eslint-disable-line no-undef
assert.equal(domids.CMDispTooltipWarningParent.style.padding, '3px 4px'); // eslint-disable-line no-undef
});
});
describe('ToolWarnPos = 1', function () {
before(function () {
CMOptions.ToolWarnPos = 1;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMDispTooltipWarningParent.style.right, 'auto'); // eslint-disable-line no-undef
assert.equal(domids.CMDispTooltipWarningParent.style.margin, '4px'); // eslint-disable-line no-undef
assert.equal(domids.CMDispTooltipWarningParent.style.padding, '4px 3px'); // eslint-disable-line no-undef
});
});
});

View File

@@ -0,0 +1,41 @@
import { before, beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import { l, Game } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleUpgradeBarAndColor from '../../../src/Config/Toggles/ToggleUpgradeBarAndColour';
describe('ToggleUpgradeBarAndColor', function () {
global.l = l;
global.Game = Game;
beforeEach(function () {
global.domids = {};
ToggleUpgradeBarAndColor();
});
describe('UpBarColor = 0', function () {
before(function () {
CMOptions.UpBarColor = 0;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMUpgradeBar.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('UpBarColor = 1', function () {
before(function () {
CMOptions.UpBarColor = 1;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMUpgradeBar.style.display, ''); // eslint-disable-line no-undef
});
});
describe('UpBarColor = 2', function () {
before(function () {
CMOptions.UpBarColor = 2;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMUpgradeBar.style.display, 'none'); // eslint-disable-line no-undef
});
});
});

View File

@@ -0,0 +1,33 @@
import { before, beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import { l } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleUpgradeBarFixedPos from '../../../src/Config/Toggles/ToggleUpgradeBarFixedPos';
describe('ToggleUpgradeBarFixedPos', function () {
global.l = l;
beforeEach(function () {
global.domids = {};
ToggleUpgradeBarFixedPos();
});
describe('UpgradeBarFixedPos = 0', function () {
before(function () {
CMOptions.UpgradeBarFixedPos = 0;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMUpgradeBar.style.position, ''); // eslint-disable-line no-undef
});
});
describe('UpgradeBarFixedPos = 1', function () {
before(function () {
CMOptions.UpgradeBarFixedPos = 1;
});
it('Toggle style correctly', function () {
assert.equal(domids.CMUpgradeBar.style.position, 'sticky'); // eslint-disable-line no-undef
assert.equal(domids.CMUpgradeBar.style.top, '0px'); // eslint-disable-line no-undef
});
});
});

View File

@@ -0,0 +1,63 @@
import { before, beforeEach, describe, it } from 'mocha';
import { assert } from 'chai';
import { l, Game } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleWrinklerButtons from '../../../src/Config/Toggles/ToggleWrinklerButtons';
describe('ToggleWrinklerButtons', function () {
global.l = l;
global.Game = Game;
beforeEach(function () {
global.domids = {};
ToggleWrinklerButtons();
});
describe('WrinklerButtons = 0', function () {
before(function () {
CMOptions.WrinklerButtons = 0;
});
describe('Game.elderWrath = 0', function () {
before(function () {
Game.elderWrath = 0;
});
it('Toggle style correctly', function () {
assert.equal(domids.PopAllNormalWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
assert.equal(domids.PopFattestWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('Game.elderWrath = 1', function () {
before(function () {
Game.elderWrath = 1;
});
it('Toggle style correctly', function () {
assert.equal(domids.PopAllNormalWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
assert.equal(domids.PopFattestWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
});
});
});
describe('WrinklerButtons = 1', function () {
before(function () {
CMOptions.WrinklerButtons = 1;
});
describe('Game.elderWrath = 0', function () {
before(function () {
Game.elderWrath = 0;
});
it('Toggle style correctly', function () {
assert.equal(domids.PopAllNormalWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
assert.equal(domids.PopFattestWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('Game.elderWrath = 1', function () {
before(function () {
Game.elderWrath = 1;
});
it('Toggle style correctly', function () {
assert.equal(domids.PopAllNormalWrinklerButton.style.display, ''); // eslint-disable-line no-undef
assert.equal(domids.PopFattestWrinklerButton.style.display, ''); // eslint-disable-line no-undef
});
});
});
});