diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-11-03 05:38:18 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-11-03 05:38:18 +0800 |
commit | d5521ea5e09f5a42471335b856989751b90184dc (patch) | |
tree | c612141ef0b2101fdfe117d5944c143ae74e7c52 /packages/instant/test/util/time.test.ts | |
parent | cc4ccda6232af470b96950a37fa1d0f4b4ef7f3a (diff) | |
parent | 6a57a7b5be151114bb06c171560976b09a8c4aa1 (diff) | |
download | dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.tar.gz dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.tar.zst dexon-sol-tools-d5521ea5e09f5a42471335b856989751b90184dc.zip |
Merge branch 'development' of https://github.com/0xProject/0x-monorepo into feature/instant/maker-asset-datas-interface
Diffstat (limited to 'packages/instant/test/util/time.test.ts')
-rw-r--r-- | packages/instant/test/util/time.test.ts | 48 |
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..fcb4e1875 --- /dev/null +++ b/packages/instant/test/util/time.test.ts @@ -0,0 +1,48 @@ +import { timeUtil } from '../../src/util/time'; + +describe('timeUtil', () => { + 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); + }); + }); + }); +}); |