Skip to content

Commit

Permalink
✅ Add bit test
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Mar 21, 2023
1 parent fcce38e commit b74bc08
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,26 @@ describe('MetricVisComponent', function () {
expect(moreThanPetaValue).toBe('1 EB');
});

it('correctly formats bits (decimal)', () => {
const base = 1000;
const bitFormat = {
id: 'number',
params: { pattern: '0.0bitd' },
};

const { primary: bytesValue } = getFormattedMetrics(base - 1, 0, bitFormat);
expect(bytesValue).toBe('999 bit');

const { primary: kiloBytesValue } = getFormattedMetrics(Math.pow(base, 1), 0, bitFormat);
expect(kiloBytesValue).toBe('1 kbit');

const { primary: megaBytesValue } = getFormattedMetrics(Math.pow(base, 2), 0, bitFormat);
expect(megaBytesValue).toBe('1 Mbit');

const { primary: moreThanPetaValue } = getFormattedMetrics(Math.pow(base, 6), 0, bitFormat);
expect(moreThanPetaValue).toBe('1 Ebit');
});

it('correctly formats durations', () => {
const { primary, secondary } = getFormattedMetrics(1, 1, {
id: 'duration',
Expand Down

0 comments on commit b74bc08

Please sign in to comment.