Skip to content

Commit

Permalink
adding tests for new formatter function
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra committed May 20, 2020
1 parent dab599f commit eea4719
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/common/test/formatters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { millisecondsToDuration } from 'common/utils';
import { Admin } from 'flyteidl';
import {
subSecondString,
unknownValueString,
Expand All @@ -10,10 +9,10 @@ import {
dateFromNow,
dateWithFromNow,
ensureUrlWithProtocol,
fixedRateToString,
formatDate,
formatDateLocalTimezone,
formatDateUTC,
leftPaddedNumber,
millisecondsToHMS,
protobufDurationToHMS
} from '../formatters';
Expand Down Expand Up @@ -177,3 +176,24 @@ describe('ensureUrlWithProtocol', () => {
})
);
});

describe('leftPaddedNumber', () => {
const cases: [number, number, string][] = [
[1, 0, '1'],
[10, 0, '10'],
[0, 1, '0'],
[0, 2, '00'],
[1, 1, '1'],
[1, 2, '01'],
[1, 3, '001'],
[10, 1, '10'],
[10, 2, '10'],
[10, 3, '010']
];

cases.forEach(([value, width, expected]) =>
it(`should produce ${expected} with input (${value}, ${width})`, () => {
expect(leftPaddedNumber(value, width)).toEqual(expected);
})
);
});

0 comments on commit eea4719

Please sign in to comment.