import { forEach } from 'ramda';

import CustomPropTypes from './customPropTypes';

describe('aspect ratio custom prop type', () => {
  const errorTestCases = ['cheese', 'test', 'test2', 'test3', '0:burger'];

  const validTestCases
    = ['1:1', '1:2', '4:3', '42:29', undefined, '2.40:1', '2.35:1'];

  const error = new Error(
    'Invalid prop format aspectRatio supplied to MediaImage'
  );

  forEach((aspectRatio) => {
    it(`knows ${aspectRatio} is invalid`, () => {
      expect(
        CustomPropTypes.aspectRatio(
          { aspectRatio }, 'aspectRatio', 'MediaImage'
        )
      ).toEqual(error);
    });
  }, errorTestCases);

  forEach((aspectRatio) => {
    it(`knows ${aspectRatio} is valid`, () => {
      expect(
        CustomPropTypes.aspectRatio(
          { aspectRatio }, 'aspectRatio', 'MediaImage'
        )
      ).not.toEqual(error);
    });
  }, validTestCases);
});
