File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import { formatDuration , formatDurationAboveMillisecond } from '../duration' ;
2+
3+ describe ( 'duration' , ( ) => {
4+ it ( 'should format duration' , ( ) => {
5+ expect ( formatDuration ( 1000 ) ) . toBe ( '1s' ) ;
6+ expect ( formatDuration ( 1500 ) ) . toBe ( '1s' ) ;
7+ expect ( formatDuration ( 1800 ) ) . toBe ( '1s' ) ;
8+ expect ( formatDuration ( 180000 ) ) . toBe ( '3m' ) ;
9+ expect ( formatDuration ( 200000 ) ) . toBe ( '3m 20s' ) ;
10+ } ) ;
11+
12+ it ( 'should not format too small duration' , ( ) => {
13+ expect ( formatDuration ( 50 ) ) . toBe ( '' ) ;
14+ expect ( formatDuration ( 500 ) ) . toBe ( '' ) ;
15+ expect ( formatDuration ( 900 ) ) . toBe ( '' ) ;
16+ } ) ;
17+
18+ it ( 'should format duration above millisecond' , ( ) => {
19+ expect ( formatDurationAboveMillisecond ( 1000 ) ) . toBe ( '1s' ) ;
20+ expect ( formatDurationAboveMillisecond ( 1500 ) ) . toBe ( '1s' ) ;
21+ expect ( formatDurationAboveMillisecond ( 1800 ) ) . toBe ( '1s' ) ;
22+ expect ( formatDurationAboveMillisecond ( 180000 ) ) . toBe ( '3m' ) ;
23+ expect ( formatDurationAboveMillisecond ( 200000 ) ) . toBe ( '3m 20s' ) ;
24+ expect ( formatDurationAboveMillisecond ( 50 ) ) . toBe ( '50ms' ) ;
25+ expect ( formatDurationAboveMillisecond ( 500 ) ) . toBe ( '500ms' ) ;
26+ expect ( formatDurationAboveMillisecond ( 900 ) ) . toBe ( '900ms' ) ;
27+ } ) ;
28+ } ) ;
You can’t perform that action at this time.
0 commit comments