/
between.test.js
58 lines (51 loc) · 1.88 KB
/
between.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// @flow
import between from '../between'
describe('between', () => {
it('should return a valid calc formula when passed min/max screen sizes', () => {
expect(between('20px', '100px', '400px', '1000px')).toMatchSnapshot()
})
it('should return a valid calc formula when not passed min/max screen sizes', () => {
expect(between('20px', '100px')).toMatchSnapshot()
})
// Errors
it('should throw an error when not passed min/max screen size as a string', () => {
expect(() => {
// $FlowFixMe
between('20px', '100px', 400, 1000)
}).toThrow(
'minScreen and maxScreen must be provided as stringified numbers with the same units.',
)
})
it('should throw an error when passed min/max screen size with different units', () => {
expect(() => {
// $FlowFixMe
between('20px', '100px', '4em', '1000px')
}).toThrow(
'minScreen and maxScreen must be provided as stringified numbers with the same units.',
)
})
it('should throw an error when passed to/from size with different units', () => {
expect(() => {
// $FlowFixMe
between('1em', '100px', '400px', '1000px')
}).toThrow(
'fromSize and toSize must be provided as stringified numbers with the same units.',
)
})
it('should throw an error when passed to/from size with different units than mix/max screen', () => {
expect(() => {
// $FlowFixMe
between('1em', '100em', '400px', '1000px')
}).toThrow(
'fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.',
)
})
it('should throw an error when passed to/from size with no units but mix/max with units', () => {
expect(() => {
// $FlowFixMe
between(20, 100)
}).toThrow(
'fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.',
)
})
})