Skip to content

Commit

Permalink
test: make ci passed
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed Sep 8, 2020
1 parent 7ee4de3 commit d94a9db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions __tests__/file-size.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fileSize } from '../src/file-size';
import { fileSize } from '../src/size';

describe('file-size', () => {
test('fileSize', async () => {
expect(await fileSize('./src/index.ts', false)).toBeGreaterThan(await fileSize('./src/index.ts', true));
expect(await fileSize('./src/cmd.ts', false)).toBeGreaterThan(await fileSize('./src/cmd.ts', true));

// expect(async () => {
// await fileSize('not-exist.ts', false)
Expand Down
40 changes: 20 additions & 20 deletions __tests__/parse-size.spec.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { parseSizeString, formatSize } from '../src/parse-size';
import { parse, format } from '../src/bytes';

describe('parse-size', () => {
test('parseSizeString', () => {
expect(parseSizeString('100')).toBe(100);
expect(parseSizeString('100b')).toBe(100);
expect(parseSizeString('100 b')).toBe(100);
expect(parseSizeString('10.1 b')).toBe(10.1);
test('parse', () => {
expect(parse('100')).toBe(100);
expect(parse('100b')).toBe(100);
expect(parse('100 b')).toBe(100);
expect(parse('10.1 b')).toBe(10.1);

expect(parseSizeString('10.1 kb')).toBe(10.1 * 1024);
expect(parseSizeString('10.1 KB')).toBe(10.1 * 1024);
expect(parse('10.1 kb')).toBe(10.1 * 1024);
expect(parse('10.1 KB')).toBe(10.1 * 1024);

expect(parseSizeString('1.2 mb')).toBe(1.2 * 1024 * 1024);
expect(parseSizeString('1.2 mb')).toBe(1.2 * 1024 * 1024);
expect(parse('1.2 mb')).toBe(1.2 * 1024 * 1024);
expect(parse('1.2 mb')).toBe(1.2 * 1024 * 1024);

expect(parseSizeString('1.2 mb')).toBe(1.2 * 1024 * 1024);
expect(parse('1.2 mb')).toBe(1.2 * 1024 * 1024);

expect(parseSizeString('1.2 Gb')).toBe(1.2 * 1024 * 1024 * 1024);
expect(parse('1.2 Gb')).toBe(1.2 * 1024 * 1024 * 1024);

expect(() => {
parseSizeString('1a.2 mb');
parse('1a.2 mb');
}).toThrow(`file size string '1a.2 mb' syntax error, e.g. 100 b, 1.2 Kb, 2 Mb, 20.5 Gb!`);
});

test('formatSize', () => {
expect(formatSize(100)).toBe('100.0 b');
expect(formatSize(10000)).toBe('9.8 Kb');
expect(formatSize(1000000)).toBe('976.6 Kb');
expect(formatSize(100000000)).toBe('95.4 Mb');
expect(formatSize(10000000000)).toBe('9.3 Gb');
expect(formatSize(1000000000000)).toBe('931.3 Gb');
test('format', () => {
expect(format(100)).toBe('100.0 b');
expect(format(10000)).toBe('9.8 Kb');
expect(format(1000000)).toBe('976.6 Kb');
expect(format(100000000)).toBe('95.4 Mb');
expect(format(10000000000)).toBe('9.3 Gb');
expect(format(1000000000000)).toBe('931.3 Gb');
});
});

0 comments on commit d94a9db

Please sign in to comment.