misc_test.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var misc = require('utils/misc');
  19. describe('misc', function () {
  20. describe('#formatBandwidth', function () {
  21. var tests = [
  22. {m:'undefined to undefined',i:undefined,e:undefined},
  23. {m:'0 to <1KB',i:'0',e:'<1KB'},
  24. {m:'1000 to <1KB',i:'1000',e:'<1KB'},
  25. {m:'1024 to 1.0KB',i:'1024',e:'1.0KB'},
  26. {m:'2048 to 2.0KB',i:'2048',e:'2.0KB'},
  27. {m:'1048576 to 1.0MB',i:'1048576',e:'1.0MB'},
  28. {m:'1782579 to 1.7MB',i:'1782579',e:'1.7MB'},
  29. {m:'1546188226 to 1.44GB',i:'1546188226',e:'1.44GB'}
  30. ];
  31. tests.forEach(function(test) {
  32. it(test.m + ' ', function () {
  33. expect(misc.formatBandwidth(test.i)).to.equal(test.e);
  34. });
  35. });
  36. it('NaN to NaN' + ' ', function () {
  37. expect(isNaN(misc.formatBandwidth(NaN))).to.equal(true);
  38. });
  39. });
  40. });