/
Utils.test.ts
44 lines (35 loc) · 1.16 KB
/
Utils.test.ts
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
import { castBreakpointsToIntegers } from "../Utils"
describe("utils functions", () => {
describe("casting breakpoints gave as either string or integers into integers", () => {
const breakpointsWithStrings = {
"extra-small": "0",
small: "768",
medium: "1024",
large: "1120",
}
const breakpointsWithIntegers = {
"extra-small": 0,
small: 768,
medium: 1024,
large: 1120,
}
const breakpointsWithMixedValues = {
"extra-small": 0,
small: 768,
medium: 1024,
large: 1120,
}
it("should return value as integers if given as strings", () => {
const results = castBreakpointsToIntegers(breakpointsWithStrings)
expect(results).toEqual(breakpointsWithIntegers)
})
it("should not touch the value if they are already numbers", () => {
const results = castBreakpointsToIntegers(breakpointsWithIntegers)
expect(results).toEqual(breakpointsWithIntegers)
})
it("should work the same with a mix of values", () => {
const results = castBreakpointsToIntegers(breakpointsWithMixedValues)
expect(results).toEqual(breakpointsWithIntegers)
})
})
})