diff options
| author | Rinpatch <rinpatch@sdf.org> | 2018-12-12 20:41:12 +0300 |
|---|---|---|
| committer | Rinpatch <rinpatch@sdf.org> | 2018-12-12 20:41:12 +0300 |
| commit | fa7fbe05decc7b5f3a52560b1f8ebe1f9b3f91ef (patch) | |
| tree | 2d622163755203a1c89746516e6c118bc75365e9 /test | |
| parent | 9c24ac1d050914861891bd1f5137159e91890d86 (diff) | |
Write a unit test for fileSizeFormatService
Diffstat (limited to 'test')
| -rw-r--r-- | test/unit/specs/services/file_size_format/file_size_format.spec.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/unit/specs/services/file_size_format/file_size_format.spec.js b/test/unit/specs/services/file_size_format/file_size_format.spec.js new file mode 100644 index 00000000..0a5a82b7 --- /dev/null +++ b/test/unit/specs/services/file_size_format/file_size_format.spec.js @@ -0,0 +1,34 @@ + import fileSizeFormatService from '../../../../../src/services/file_size_format/file_size_format.js' + describe('fileSizeFormat', () => { + it('Formats file size', () => { + const values = [1, 1024, 1048576, 1073741824, 1099511627776] + const expected = [ + { + num: 1, + unit: 'B' + }, + { + num: 1, + unit: 'KiB' + }, + { + num: 1, + unit: 'MiB' + }, + { + num: 1, + unit: 'GiB' + }, + { + num: 1, + unit: 'TiB' + } + ] + + var res = [] + for (var value in values) { + res.push(fileSizeFormatService.fileSizeFormat(values[value])) + } + expect(res).to.eql(expected) + }) + }) |
