From 8ce4e1364696137801a59eec2b723f147c095032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Tue, 13 Apr 2021 00:03:35 +0200 Subject: [PATCH] Added additional tests --- .../t_BeautifyFormatting.js} | 0 test/t_Disp/t_GetTimeColour.js | 48 +++++++++++++++++++ 2 files changed, 48 insertions(+) rename test/{Test_Disp/Test_BeautifyFormatting.js => t_Disp/t_BeautifyFormatting.js} (100%) create mode 100644 test/t_Disp/t_GetTimeColour.js diff --git a/test/Test_Disp/Test_BeautifyFormatting.js b/test/t_Disp/t_BeautifyFormatting.js similarity index 100% rename from test/Test_Disp/Test_BeautifyFormatting.js rename to test/t_Disp/t_BeautifyFormatting.js diff --git a/test/t_Disp/t_GetTimeColour.js b/test/t_Disp/t_GetTimeColour.js new file mode 100644 index 0000000..5b3ba2e --- /dev/null +++ b/test/t_Disp/t_GetTimeColour.js @@ -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', + }); + }); + }); +});