Merge pull request #770 from DanielNoord/tests

Tests
This commit is contained in:
Daniël van Noord
2021-04-13 00:05:14 +02:00
committed by GitHub
9 changed files with 763 additions and 590 deletions

View File

@@ -1,4 +1,5 @@
{ {
"recursive": true, "recursive": true,
"require": "esm" "require": "esm",
"reporter": "min"
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1290
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@
], ],
"scripts": { "scripts": {
"copy-file": "cp dist/CookieMonster.js CookieMonster.js", "copy-file": "cp dist/CookieMonster.js CookieMonster.js",
"eslint-src": "eslint src", "eslint-src": "eslint src test",
"build": "run-s eslint-src pack-prod remove-comment copy-file test", "build": "run-s eslint-src pack-prod remove-comment copy-file test",
"build-test": "run-s pack-dev", "build-test": "run-s pack-dev",
"pack-prod": "webpack --env production", "pack-prod": "webpack --env production",

View File

@@ -1,6 +1,6 @@
import jscolor from '@eastdesire/jscolor'; import jscolor from '@eastdesire/jscolor';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import Beautify from '../../Disp/BeautifyAndFormatting/Beautify'; import CMBeautify from '../../Disp/BeautifyAndFormatting/Beautify';
import FormatTime from '../../Disp/BeautifyAndFormatting/FormatTime'; import FormatTime from '../../Disp/BeautifyAndFormatting/FormatTime';
import { AddAuraInfo, AddDragonLevelUpTooltip } from '../../Disp/Dragon/Dragon'; import { AddAuraInfo, AddDragonLevelUpTooltip } from '../../Disp/Dragon/Dragon';
import AddMenu from '../../Disp/MenuSections/AddMenus'; import AddMenu from '../../Disp/MenuSections/AddMenus';
@@ -144,7 +144,7 @@ export default function ReplaceNative() {
let title = 'Cookie Clicker'; let title = 'Cookie Clicker';
if (Game.season === 'fools') title = 'Cookie Baker'; if (Game.season === 'fools') title = 'Cookie Baker';
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
Title = `${Game.OnAscend ? 'Ascending! ' : ''}${Beautify(Game.cookies)} ${ Title = `${Game.OnAscend ? 'Ascending! ' : ''}${CMBeautify(Game.cookies)} ${
Game.cookies === 1 ? 'cookie' : 'cookies' Game.cookies === 1 ? 'cookie' : 'cookies'
} - ${title}`; } - ${title}`;
UpdateTitle(); UpdateTitle();

View File

@@ -0,0 +1,48 @@
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',
});
});
});
});