1 | import cssSerialiser from './helpers/cssSerialiser';
|
2 | import {
|
3 | mqWithValidBreakpointsForRange,
|
4 | mqWithTweakedBreakpointsForRange,
|
5 | } from './data';
|
6 |
|
7 | expect.addSnapshotSerializer(cssSerialiser);
|
8 |
|
9 | describe('tweak()', () => {
|
10 | it('throws if invalid breakpoint value is supplied', () => {
|
11 | expect(() =>
|
12 | mqWithValidBreakpointsForRange('width').tweak({ width: { small: 'xxx' } })
|
13 | ).toThrowErrorMatchingSnapshot();
|
14 | });
|
15 | });
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | describe('tweaked()', () => {
|
22 | it('throws when accessing original without an original object', () => {
|
23 | expect(() =>
|
24 | mqWithValidBreakpointsForRange('width').untweaked()
|
25 | ).toThrowErrorMatchingSnapshot();
|
26 | });
|
27 |
|
28 | it('includes original breakpoints and added tweakpoints', () => {
|
29 | expect(
|
30 | mqWithTweakedBreakpointsForRange('width').aboveWidth('alpha')
|
31 | ).toMatchSnapshot();
|
32 |
|
33 | expect(
|
34 | mqWithTweakedBreakpointsForRange('width').betweenWidths('alpha', 'large')
|
35 | ).toMatchSnapshot();
|
36 | });
|
37 |
|
38 | it("doesn't effect the original mq", () => {
|
39 | expect(() =>
|
40 | mqWithTweakedBreakpointsForRange('width')
|
41 | .untweaked()
|
42 | .aboveWidth('alpha')
|
43 | ).toThrowErrorMatchingSnapshot();
|
44 |
|
45 |
|
46 | expect(
|
47 | mqWithTweakedBreakpointsForRange('width')
|
48 | .untweaked()
|
49 | .atWidthBreakpoint('small')
|
50 | ).toMatchSnapshot();
|
51 | });
|
52 | });
|