Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
test: add parseWidthOrHeight test
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw committed Jun 11, 2019
1 parent e0cac74 commit 53c51cb
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import parseWidthOrHeight from '../../src/components/parseWidthOrHeight';

describe('parseWidthOrHeight(input)', () => {
it('handles string "auto"', () => {
expect(parseWidthOrHeight('auto')).toEqual({ isDynamic: true, multiplier: 1 });
});
it('handles strings with % at the end', () => {
expect(parseWidthOrHeight('100%')).toEqual({ isDynamic: true, multiplier: 1 });
expect(parseWidthOrHeight('50%')).toEqual({ isDynamic: true, multiplier: 0.5 });
expect(parseWidthOrHeight('0%')).toEqual({ isDynamic: true, multiplier: 0 });
});
it('handles strings that are numbers', () => {
expect(parseWidthOrHeight('100')).toEqual({ isDynamic: false, value: 100 });
expect(parseWidthOrHeight('20')).toEqual({ isDynamic: false, value: 20 });
});
it('handles numbers', () => {
expect(parseWidthOrHeight(100)).toEqual({ isDynamic: false, value: 100 });
expect(parseWidthOrHeight(0)).toEqual({ isDynamic: false, value: 0 });
});
});

0 comments on commit 53c51cb

Please sign in to comment.