All files / nexshop-web-contents/spec/helpers utility-spec.js

100% Statements 22/22
100% Branches 0/0
100% Functions 9/9
100% Lines 22/22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 391x 1x 1x   1x   1x 1x 1x 1x 1x 1x     1x 1x     1x 1x     1x 1x     1x 1x     1x 1x     1x 1x      
import React from 'react';
import {expect} from 'chai';
import {convertBytesToKilobytes} from "../../src/helpers/utility";
 
describe('Utility Spec', () => {
 
    describe('file size Helper spec', () => {
        it('return "0B" when file size is undefined, null, zero or minus', () => {
            expect(convertBytesToKilobytes(undefined)).to.equal('0B');
            expect(convertBytesToKilobytes(null)).to.equal('0B');
            expect(convertBytesToKilobytes(0)).to.equal('0B');
            expect(convertBytesToKilobytes(-1)).to.equal('0B');
        });
 
        it('return "1023B" when file size is 1023byte', () => {
            expect(convertBytesToKilobytes(1023)).to.equal('1023B');
        });
 
        it('return "1.0KB" when file size is 1024byte', () => {
            expect(convertBytesToKilobytes(1024)).to.equal('1.0KB');
        });
 
        it('return "1.0KB" when file size is 1025B', () => {
            expect(convertBytesToKilobytes(1025)).to.equal('1.0KB');
        });
 
        it('return "1.0MB" when file size is 1048576', () => {
            expect(convertBytesToKilobytes(1048576)).to.equal('1.0MB');
        });
 
        it('return "1024.0KB" when file size is 1048575', () => {
            expect(convertBytesToKilobytes(1048575)).to.equal('1.0MB');
        });
 
        it('return "1.0GB" when file size is 1073741824', () => {
            expect(convertBytesToKilobytes(1073741824)).to.equal('1.0GB');
        });
    });
});