aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/test
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-31 11:18:21 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-10-31 11:18:21 +0800
commit229f11f164ce5109b771295d9aee8ebb74314181 (patch)
treead4cdcc1926a1e7ec563f331c8f1edba7770b867 /packages/instant/test
parent0e1e9b27f6f5b93e1f9b0e2833bc600836f8e757 (diff)
downloaddexon-sol-tools-229f11f164ce5109b771295d9aee8ebb74314181.tar.gz
dexon-sol-tools-229f11f164ce5109b771295d9aee8ebb74314181.tar.zst
dexon-sol-tools-229f11f164ce5109b771295d9aee8ebb74314181.zip
Nice formatting of displayed time
Diffstat (limited to 'packages/instant/test')
-rw-r--r--packages/instant/test/util/time.test.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/instant/test/util/time.test.ts b/packages/instant/test/util/time.test.ts
new file mode 100644
index 000000000..7165761de
--- /dev/null
+++ b/packages/instant/test/util/time.test.ts
@@ -0,0 +1,48 @@
+import { timeUtil } from '../../src/util/time';
+
+describe('assetDataUtil', () => {
+ describe('secondsToHumanDescription', () => {
+ const numsToResults: {
+ [aNumber: number]: string;
+ } = {
+ 1: '1 second',
+ 59: '59 seconds',
+ 60: '1 minute',
+ 119: '1 minute 59 seconds',
+ 120: '2 minutes',
+ 121: '2 minutes 1 second',
+ 122: '2 minutes 2 seconds',
+ };
+
+ const nums = Object.keys(numsToResults);
+ nums.forEach(aNum => {
+ const numInt = parseInt(aNum, 10);
+ it(`should work for ${aNum} seconds`, () => {
+ const expectedResult = numsToResults[numInt];
+ expect(timeUtil.secondsToHumanDescription(numInt)).toEqual(expectedResult);
+ });
+ });
+ });
+ describe('secondsToStopwatchTime', () => {
+ const numsToResults: {
+ [aNumber: number]: string;
+ } = {
+ 1: '00:01',
+ 59: '00:59',
+ 60: '01:00',
+ 119: '01:59',
+ 120: '02:00',
+ 121: '02:01',
+ 2701: '45:01',
+ };
+
+ const nums = Object.keys(numsToResults);
+ nums.forEach(aNum => {
+ const numInt = parseInt(aNum, 10);
+ it(`should work for ${aNum} seconds`, () => {
+ const expectedResult = numsToResults[numInt];
+ expect(timeUtil.secondsToStopwatchTime(numInt)).toEqual(expectedResult);
+ });
+ });
+ });
+});