Added testing via Mocha
This commit is contained in:
4
.mocharc.json
Normal file
4
.mocharc.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"recursive": true,
|
||||
"require": "esm"
|
||||
}
|
||||
15651
package-lock.json
generated
15651
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
139
package.json
139
package.json
@@ -1,71 +1,76 @@
|
||||
{
|
||||
"name": "cookiemonster-mod",
|
||||
"version": "2.031.7",
|
||||
"description": "Cookie Monster is an add-on that you can load into Cookie Clicker which offers a wide range of tools and statistics to enhance the game. It is not a cheat interface – although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want. This is a helper and everything is an option.",
|
||||
"main": "CookieMonster.js",
|
||||
"keywords": [
|
||||
"Cookie Clicker",
|
||||
"javascript",
|
||||
"mod",
|
||||
"Dashnet",
|
||||
"Orteil"
|
||||
],
|
||||
"scripts": {
|
||||
"copy-file": "cp dist/CookieMonster.js CookieMonster.js",
|
||||
"eslint-src": "eslint src",
|
||||
"build": "run-s eslint-src pack-prod remove-comment copy-file",
|
||||
"build-test": "run-s pack-dev",
|
||||
"pack-prod": "webpack --env production",
|
||||
"pack-dev": "webpack",
|
||||
"remove-comment": "sed -i '' -e '/\\/\\/# sourceMappingURL.*/d' dist/CookieMonster.js"
|
||||
"name": "cookiemonster-mod",
|
||||
"version": "2.031.7",
|
||||
"description": "Cookie Monster is an add-on that you can load into Cookie Clicker which offers a wide range of tools and statistics to enhance the game. It is not a cheat interface – although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want. This is a helper and everything is an option.",
|
||||
"main": "CookieMonster.js",
|
||||
"keywords": [
|
||||
"Cookie Clicker",
|
||||
"javascript",
|
||||
"mod",
|
||||
"Dashnet",
|
||||
"Orteil"
|
||||
],
|
||||
"scripts": {
|
||||
"copy-file": "cp dist/CookieMonster.js CookieMonster.js",
|
||||
"eslint-src": "eslint src",
|
||||
"build": "run-s eslint-src pack-prod remove-comment copy-file",
|
||||
"build-test": "run-s pack-dev",
|
||||
"pack-prod": "webpack --env production",
|
||||
"pack-dev": "webpack",
|
||||
"remove-comment": "sed -i '' -e '/\\/\\/# sourceMappingURL.*/d' dist/CookieMonster.js",
|
||||
"test": "mocha"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Aktanusa/CookieMonster.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Aktanusa",
|
||||
"email": "chanam.geo@yahoo.com"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Daniël van Noord",
|
||||
"email": "13665637+DanielNoord@users.noreply.github.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Aktanusa/CookieMonster.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Aktanusa",
|
||||
"email": "chanam.geo@yahoo.com"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Daniël van Noord",
|
||||
"email": "13665637+DanielNoord@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Aran Leite",
|
||||
"email": "hyoretsu@gmail.com",
|
||||
"url": "https://www.linkedin.com/in/aranleite"
|
||||
}
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/Aktanusa/CookieMonster/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Aktanusa/CookieMonster#readme",
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^4.21.0",
|
||||
"@typescript-eslint/parser": "^4.21.0",
|
||||
"eslint": "^7.23.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "2.2.1",
|
||||
"ts-loader": "^8.1.0",
|
||||
"typescript": "^4.2.3",
|
||||
"webpack": "^5.24.4",
|
||||
"webpack-cli": "^4.5.0"
|
||||
},
|
||||
"ccrepo": {
|
||||
"icon": [
|
||||
10,
|
||||
0
|
||||
],
|
||||
"name": "Cookie Monster"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eastdesire/jscolor": "^2.4.5"
|
||||
{
|
||||
"name": "Aran Leite",
|
||||
"email": "hyoretsu@gmail.com",
|
||||
"url": "https://www.linkedin.com/in/aranleite"
|
||||
}
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/Aktanusa/CookieMonster/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Aktanusa/CookieMonster#readme",
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^4.21.0",
|
||||
"@typescript-eslint/parser": "^4.21.0",
|
||||
"chai": "^4.3.4",
|
||||
"eslint": "^7.23.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"esm": "^3.2.25",
|
||||
"mocha": "^8.3.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "2.2.1",
|
||||
"sinon": "^10.0.0",
|
||||
"ts-loader": "^8.1.0",
|
||||
"typescript": "^4.2.3",
|
||||
"webpack": "^5.24.4",
|
||||
"webpack-cli": "^4.5.0"
|
||||
},
|
||||
"ccrepo": {
|
||||
"icon": [
|
||||
10,
|
||||
0
|
||||
],
|
||||
"name": "Cookie Monster"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eastdesire/jscolor": "^2.4.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,106 @@
|
||||
/* global describe, it */
|
||||
const { assert } = require('../../node_modules/chai/chai');
|
||||
const {
|
||||
FormatTime,
|
||||
} = require('../../src/Disp/BeautifyAndFormatting/Beautify');
|
||||
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('should return -1 when the value is not present', function () {
|
||||
assert.equal(FormatTime(1, 0), '1 s');
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user