Added tests for Toggles
This commit is contained in:
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js
vendored
2
dist/CookieMonster.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js.map
vendored
2
dist/CookieMonster.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -101,7 +101,7 @@ export let TooltipWrinkler = -1; // eslint-disable-line prefer-const
|
||||
export let TooltipWrinklerBeingShown = []; // eslint-disable-line prefer-const
|
||||
|
||||
export let CMLastAscendState;
|
||||
export let CMSayTime;
|
||||
export let CMSayTime = function () {}; // eslint-disable-line prefer-const
|
||||
|
||||
/**
|
||||
* These are variables used to create various displays when the game is loaded on the "sell all" screen
|
||||
|
||||
@@ -4,7 +4,9 @@ export function l(id) {
|
||||
}
|
||||
|
||||
export const Game = {
|
||||
DrawBackground() {},
|
||||
Background: { canvas: { parentNode: {} } },
|
||||
DrawBackground() {},
|
||||
LeftBackground: { canvas: { parentNode: {} } },
|
||||
RebuildUpgrades() {},
|
||||
UpgradesInStore: {},
|
||||
};
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
import { before, describe, it } from 'mocha';
|
||||
import { assert } from 'chai';
|
||||
|
||||
import FormatTime from '../../src/Disp/BeautifyAndFormatting/FormatTime';
|
||||
import { CMOptions } from '../../src/Config/VariablesAndData';
|
||||
|
||||
describe('FormatTime', function () {
|
||||
it('Format when time is Infinity', function () {
|
||||
assert.equal(FormatTime(Infinity, 0), Infinity);
|
||||
});
|
||||
it('Format when time is negative', function () {
|
||||
assert.equal(FormatTime(-1, 0), 'Negative time period');
|
||||
});
|
||||
describe('TimeFormat = 0', function () {
|
||||
before(function () {
|
||||
CMOptions.TimeFormat = 0;
|
||||
});
|
||||
describe('Longformat = 0', function () {
|
||||
it('Format when time is 0', function () {
|
||||
assert.equal(FormatTime(0, 0), '0s');
|
||||
});
|
||||
it('Format when time is 1 second', function () {
|
||||
assert.equal(FormatTime(1, 0), '1s');
|
||||
});
|
||||
it('Format when time is over 1 minute', function () {
|
||||
assert.equal(FormatTime(61, 0), '1m, 1s');
|
||||
});
|
||||
it('Format when time is over 1 hour', function () {
|
||||
assert.equal(FormatTime(3601, 0), '1h, 0m, 1s');
|
||||
});
|
||||
it('Format when time is over 1 day', function () {
|
||||
assert.equal(FormatTime(86401, 0), '1d, 0h, 0m, 1s');
|
||||
});
|
||||
it('Format when time is over 1 year', function () {
|
||||
assert.equal(FormatTime(31536001, 0), '1y, 0d, 0h, 0m, 1s');
|
||||
});
|
||||
it('Format when time is over >9000 days', function () {
|
||||
assert.equal(FormatTime(777600001, 0), '>9000d');
|
||||
});
|
||||
it('Format when time is over >99.9 years', function () {
|
||||
assert.equal(FormatTime(3155760001, 0), '>9000d');
|
||||
});
|
||||
});
|
||||
describe('Longformat = 1', function () {
|
||||
it('Format when time is 0', function () {
|
||||
assert.equal(FormatTime(0, 1), '0 seconds');
|
||||
});
|
||||
it('Format when time is 1 second', function () {
|
||||
assert.equal(FormatTime(1, 1), '1 second');
|
||||
});
|
||||
it('Format when time is over 1 minute', function () {
|
||||
assert.equal(FormatTime(61, 1), '1 minute, 1 second');
|
||||
});
|
||||
it('Format when time is over 1 hour', function () {
|
||||
assert.equal(FormatTime(3601, 1), '1 hour, 0 minutes, 1 second');
|
||||
});
|
||||
it('Format when time is over 1 day', function () {
|
||||
assert.equal(
|
||||
FormatTime(86401, 1),
|
||||
'1 day, 0 hours, 0 minutes, 1 second',
|
||||
);
|
||||
});
|
||||
it('Format when time is over 1 year', function () {
|
||||
assert.equal(
|
||||
FormatTime(31536001, 1),
|
||||
'1 year, 0 days, 0 hours, 0 minutes, 1 second',
|
||||
);
|
||||
});
|
||||
it('Format when time is over >9000 days', function () {
|
||||
assert.equal(FormatTime(777600001, 1), 'Over 9000 days!');
|
||||
});
|
||||
it('Format when time is over >99.9 years', function () {
|
||||
assert.equal(FormatTime(3155760001, 1), 'Over 9000 days!');
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('TimeFormat = 1', function () {
|
||||
before(function () {
|
||||
CMOptions.TimeFormat = 1;
|
||||
});
|
||||
it('Format when time is 0', function () {
|
||||
assert.equal(FormatTime(0, 0), '00:00:00:00:00');
|
||||
});
|
||||
it('Format when time is 1 second', function () {
|
||||
assert.equal(FormatTime(1, 0), '00:00:00:00:01');
|
||||
});
|
||||
it('Format when time is over 1 minute', function () {
|
||||
assert.equal(FormatTime(61, 0), '00:00:00:01:01');
|
||||
});
|
||||
it('Format when time is over 1 hour', function () {
|
||||
assert.equal(FormatTime(3601, 0), '00:00:01:00:01');
|
||||
});
|
||||
it('Format when time is over 1 day', function () {
|
||||
assert.equal(FormatTime(86401, 0), '00:01:00:00:01');
|
||||
});
|
||||
it('Format when time is over 1 year', function () {
|
||||
assert.equal(FormatTime(31536001, 0), '01:00:00:00:01');
|
||||
});
|
||||
it('Format when time is over >9000 days', function () {
|
||||
assert.equal(FormatTime(777600001, 0), '24:240:00:00:01');
|
||||
});
|
||||
it('Format when time is over >99.9 years', function () {
|
||||
assert.equal(FormatTime(3155760001, 0), 'XX:XX:XX:XX:XX');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,48 +0,0 @@
|
||||
import { before, describe, it } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import GetTimeColour from '../../src/Disp/BeautifyAndFormatting/GetTimeColour';
|
||||
import { CMOptions } from '../../src/Config/VariablesAndData';
|
||||
|
||||
describe('GetTimeColour', function () {
|
||||
it('Format when time is less than 60', function () {
|
||||
expect(GetTimeColour(59).color).to.deep.equal('Yellow');
|
||||
});
|
||||
it('Format when time is more than 60', function () {
|
||||
expect(GetTimeColour(61).color).to.deep.equal('Orange');
|
||||
});
|
||||
it('Format when time is more than 300', function () {
|
||||
expect(GetTimeColour(301).color).to.deep.equal('Red');
|
||||
});
|
||||
describe('TimeFormat = 0', function () {
|
||||
before(function () {
|
||||
CMOptions.TimeFormat = 0;
|
||||
});
|
||||
it('Format when time is 0', function () {
|
||||
expect(GetTimeColour(0)).to.deep.equal({ text: 'Done!', color: 'Green' });
|
||||
});
|
||||
it('Format when time is negative', function () {
|
||||
expect(GetTimeColour(-1)).to.deep.equal({
|
||||
text: 'Done!',
|
||||
color: 'Green',
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('TimeFormat = 1', function () {
|
||||
before(function () {
|
||||
CMOptions.TimeFormat = 1;
|
||||
});
|
||||
it('Format when time is 0', function () {
|
||||
expect(GetTimeColour(0)).to.deep.equal({
|
||||
text: '00:00:00:00:00',
|
||||
color: 'Green',
|
||||
});
|
||||
});
|
||||
it('Format when time is negative', function () {
|
||||
expect(GetTimeColour(-1)).to.deep.equal({
|
||||
text: '00:00:00:00:00',
|
||||
color: 'Green',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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';
|
||||
|
||||
33
test/t_Config/t_Toggles/t_ToggleDetailedTime.js
Normal file
33
test/t_Config/t_Toggles/t_ToggleDetailedTime.js
Normal 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');
|
||||
});
|
||||
});
|
||||
});
|
||||
17
test/t_Config/t_Toggles/t_ToggleFavourites.js
Normal file
17
test/t_Config/t_Toggles/t_ToggleFavourites.js
Normal 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']);
|
||||
});
|
||||
});
|
||||
46
test/t_Config/t_Toggles/t_ToggleGCTimer.js
Normal file
46
test/t_Config/t_Toggles/t_ToggleGCTimer.js
Normal 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');
|
||||
});
|
||||
});
|
||||
});
|
||||
32
test/t_Config/t_Toggles/t_ToggleSectionHideButtons.js
Normal file
32
test/t_Config/t_Toggles/t_ToggleSectionHideButtons.js
Normal 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
|
||||
});
|
||||
});
|
||||
});
|
||||
36
test/t_Config/t_Toggles/t_ToggleToolWarnPos.js
Normal file
36
test/t_Config/t_Toggles/t_ToggleToolWarnPos.js
Normal 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
|
||||
});
|
||||
});
|
||||
});
|
||||
41
test/t_Config/t_Toggles/t_ToggleUpgradeBarAndColour.js
Normal file
41
test/t_Config/t_Toggles/t_ToggleUpgradeBarAndColour.js
Normal 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
|
||||
});
|
||||
});
|
||||
});
|
||||
33
test/t_Config/t_Toggles/t_ToggleUpgradeBarFixedPos.js
Normal file
33
test/t_Config/t_Toggles/t_ToggleUpgradeBarFixedPos.js
Normal 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
|
||||
});
|
||||
});
|
||||
});
|
||||
63
test/t_Config/t_Toggles/t_ToggleWrinklerButtons.js
Normal file
63
test/t_Config/t_Toggles/t_ToggleWrinklerButtons.js
Normal 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
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user