1 | import { values, drop } from 'ramda';
|
2 | import { MEDIA_TYPES } from '../const';
|
3 | import { mqWithValidBreakpointsForRange } from './data';
|
4 | import cssSerialiser from './helpers/cssSerialiser';
|
5 |
|
6 | expect.addSnapshotSerializer(cssSerialiser);
|
7 | const validValues = values(MEDIA_TYPES);
|
8 |
|
9 | describe('mediaTypes', () => {
|
10 | it('returns the correct default media type if called with no arguments', () => {
|
11 | expect(
|
12 | mqWithValidBreakpointsForRange('width').mediaType()
|
13 | ).toMatchSnapshot();
|
14 | });
|
15 |
|
16 | for (const value of validValues) {
|
17 | it(`returns the supplied mediaTypes for '${value}'`, () => {
|
18 | expect(
|
19 | mqWithValidBreakpointsForRange('width').mediaType(value)
|
20 | ).toMatchSnapshot();
|
21 | });
|
22 | }
|
23 |
|
24 | it('supports multiple values', () => {
|
25 | expect(
|
26 | mqWithValidBreakpointsForRange('width').mediaType(drop(2, validValues))
|
27 | ).toMatchSnapshot();
|
28 | });
|
29 | const invalidMediaTypes = ['', true, false, 'xxxx', 444, {}, []];
|
30 |
|
31 | for (const value of invalidMediaTypes) {
|
32 | it(`throws if argument is '${value}'`, () => {
|
33 | expect(() =>
|
34 | mqWithValidBreakpointsForRange('width').mediaType(value)
|
35 | ).toThrowErrorMatchingSnapshot();
|
36 | });
|
37 | }
|
38 | });
|