|
| 1 | +// Copyright 2015 Google Inc. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +import filtersModule from 'common/filters/filters_module'; |
| 16 | + |
| 17 | +describe('Memory filter', () => { |
| 18 | + /** @type {function(!number):string} */ |
| 19 | + let memoryFilter; |
| 20 | + |
| 21 | + beforeEach(() => { |
| 22 | + angular.mock.module(filtersModule.name); |
| 23 | + angular.mock.inject((_kdMemoryFilter_) => { memoryFilter = _kdMemoryFilter_; }); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should format memory', () => { |
| 27 | + expect(memoryFilter(0)).toEqual('0 B'); |
| 28 | + expect(memoryFilter(1)).toEqual('1 B'); |
| 29 | + expect(memoryFilter(2)).toEqual('2 B'); |
| 30 | + expect(memoryFilter(1000)).toEqual('1,000 B'); |
| 31 | + expect(memoryFilter(1024)).toEqual('1,024 B'); |
| 32 | + expect(memoryFilter(1025)).toEqual('1.001 KiB'); |
| 33 | + expect(memoryFilter(7896)).toEqual('7.711 KiB'); |
| 34 | + expect(memoryFilter(109809)).toEqual('107.235 KiB'); |
| 35 | + expect(memoryFilter(768689899)).toEqual('733.080 MiB'); |
| 36 | + expect(memoryFilter(768689899789)).toEqual('715.898 GiB'); |
| 37 | + expect(memoryFilter(76868989978978)).toEqual('69.912 TiB'); |
| 38 | + expect(memoryFilter(7686898997897878)).toEqual('6.827 PiB'); |
| 39 | + expect(memoryFilter(768689899789787867898766)).toEqual('682,733,780.435 PiB'); |
| 40 | + }); |
| 41 | +}); |
0 commit comments