pgadmin4/web/regression/javascript/size_prettify_spec.js

69 lines
1.9 KiB
JavaScript
Raw Normal View History

//////////////////////////////////////////////////////////////////////////
//
// pgAdmin 4 - PostgreSQL Tools
//
2020-01-02 08:43:50 -06:00
// Copyright (C) 2013 - 2020, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
2017-06-12 10:55:14 -05:00
define(['sources/size_prettify'], function (sizePrettify) {
describe('sizePrettify', function () {
describe('when size is 0', function () {
it('returns 0 bytes', function () {
expect(sizePrettify(0)).toEqual('0 bytes');
});
});
2017-06-12 10:55:14 -05:00
describe('when size >= 10kB and size < 10 MB', function () {
it('returns size in kB', function () {
expect(sizePrettify(10240)).toEqual('10 kB');
});
2017-06-12 10:55:14 -05:00
it('returns size in kB', function () {
expect(sizePrettify(99999)).toEqual('98 kB');
});
});
2017-06-12 10:55:14 -05:00
describe('when size >= 10MB and size < 10 GB', function () {
it('returns size in MB', function () {
expect(sizePrettify(10485760)).toEqual('10 MB');
});
2017-06-12 10:55:14 -05:00
it('returns size in MB', function () {
expect(sizePrettify(44040192)).toEqual('42 MB');
});
});
2017-06-12 10:55:14 -05:00
describe('when size >= 10GB and size < 10 TB', function () {
it('returns size in GB', function () {
expect(sizePrettify(10737418240)).toEqual('10 GB');
});
2017-06-12 10:55:14 -05:00
it('returns size in GB', function () {
expect(sizePrettify(10736344498176)).toEqual('9999 GB');
});
});
2017-06-12 10:55:14 -05:00
describe('when size >= 10TB and size < 10 PB', function () {
it('returns size in TB', function () {
expect(sizePrettify(10995116277760)).toEqual('10 TB');
});
2017-06-12 10:55:14 -05:00
it('returns size in TB', function () {
expect(sizePrettify(29995116277760)).toEqual('27 TB');
});
});
2017-06-12 10:55:14 -05:00
describe('when size >= 10 PB', function () {
it('returns size in PB', function () {
expect(sizePrettify(11258999068426200)).toEqual('10 PB');
});
});
});
});