2017-03-30 22:29:43 +00:00
|
|
|
import {formatBytes, formatRPDuration} from 'utils/formatting'
|
2016-09-15 21:53:29 +00:00
|
|
|
|
|
|
|
describe('Formatting helpers', () => {
|
|
|
|
describe('formatBytes', () => {
|
|
|
|
it('returns null when passed a falsey value', () => {
|
2017-03-30 22:29:43 +00:00
|
|
|
const actual = formatBytes(null)
|
2016-09-15 21:53:29 +00:00
|
|
|
|
2017-03-30 22:29:43 +00:00
|
|
|
expect(actual).to.equal(null)
|
|
|
|
})
|
2016-09-15 21:53:29 +00:00
|
|
|
|
|
|
|
it('returns the correct value when passed 0', () => {
|
2017-03-30 22:29:43 +00:00
|
|
|
const actual = formatBytes(0)
|
2016-09-15 21:53:29 +00:00
|
|
|
|
2017-03-30 22:29:43 +00:00
|
|
|
expect(actual).to.equal('0 Bytes')
|
|
|
|
})
|
2016-09-15 21:53:29 +00:00
|
|
|
|
2017-06-07 16:23:53 +00:00
|
|
|
it("converts a raw byte value into it's most appropriate unit", () => {
|
2017-03-30 22:29:43 +00:00
|
|
|
expect(formatBytes(1000)).to.equal('1 KB')
|
|
|
|
expect(formatBytes(1000000)).to.equal('1 MB')
|
|
|
|
expect(formatBytes(1000000000)).to.equal('1 GB')
|
|
|
|
})
|
|
|
|
})
|
2016-09-15 21:53:29 +00:00
|
|
|
|
|
|
|
describe('formatRPDuration', () => {
|
|
|
|
it("returns 'infinite' for a retention policy with a value of '0'", () => {
|
|
|
|
const actual = formatRPDuration('0')
|
|
|
|
|
2017-03-30 22:29:43 +00:00
|
|
|
expect(actual).to.equal('∞')
|
|
|
|
})
|
2016-09-15 21:53:29 +00:00
|
|
|
|
|
|
|
it('correctly formats retention policy durations', () => {
|
2017-03-30 22:29:43 +00:00
|
|
|
expect(formatRPDuration('24h0m0s')).to.equal('24h')
|
2016-09-15 21:53:29 +00:00
|
|
|
|
2017-03-30 22:29:43 +00:00
|
|
|
expect(formatRPDuration('168h0m0s')).to.equal('7d')
|
2016-09-15 21:53:29 +00:00
|
|
|
|
2017-03-30 22:29:43 +00:00
|
|
|
expect(formatRPDuration('200h32m3s')).to.equal('8d8h32m3s')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|