File size: 2,891 Bytes
1e92f2d |
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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
import { AspectRatios } from 'calypso/state/editor/image-editor/constants';
import { getDefaultAspectRatio } from '../utils';
describe( 'getDefaultAspectRatio', () => {
describe( 'when only aspectRatio is given', () => {
describe( 'when aspectRatio is valid', () => {
it( 'returns the aspectRatio', () => {
const expected = 'ASPECT_1X1';
const actual = getDefaultAspectRatio( 'ASPECT_1X1' );
expect( actual ).toEqual( expected );
} );
} );
describe( 'when aspectRatio is invalid', () => {
it( 'returns the value of AspectRatios.FREE', () => {
const expected = AspectRatios.FREE;
const actual = getDefaultAspectRatio( 'INVALID_ASPECT' );
expect( actual ).toEqual( expected );
} );
} );
} );
describe( 'when only aspectRatios is given', () => {
describe( 'when aspectRatios is valid', () => {
it( 'returns the first given aspectRatio', () => {
const expected = 'ASPECT_1X1';
const actual = getDefaultAspectRatio( null, [ 'ASPECT_1X1' ] );
expect( actual ).toEqual( expected );
} );
} );
describe( 'when aspectRatios is invalid', () => {
it( 'returns the value of AspectRatios.FREE', () => {
const expected = AspectRatios.FREE;
const actual = getDefaultAspectRatio( null, [ 'INVALID_ASPECT' ] );
expect( actual ).toEqual( expected );
} );
} );
} );
describe( 'when both aspectRatio & aspectRatios are given', () => {
describe( 'when aspectRatios includes the given aspectRatio', () => {
describe( 'when the given aspectRatio is valid', () => {
it( 'returns the given aspectRatio', () => {
const expected = 'ASPECT_1X1';
const actual = getDefaultAspectRatio( 'ASPECT_1X1', [ 'INVALID_ASPECT', 'ASPECT_1X1' ] );
expect( actual ).toEqual( expected );
} );
} );
describe( 'when the given aspectRatio is invalid', () => {
it( 'returns the value of AspectRatios.FREE', () => {
const expected = AspectRatios.FREE;
const actual = getDefaultAspectRatio( 'INVALID_ASPECT', [
'INVALID_ASPECT',
'ASPECT_1X1',
] );
expect( actual ).toEqual( expected );
} );
} );
} );
describe( 'when aspectRatios does not include the given aspectRatio', () => {
describe( 'when the given aspectRatios starts with a valid aspectRatio', () => {
it( 'returns that valid aspectRatio', () => {
const expected = 'ASPECT_1X1';
const actual = getDefaultAspectRatio( 'INVALID_ASPECT', [ 'ASPECT_1X1' ] );
expect( actual ).toEqual( expected );
} );
} );
describe( 'when the given aspectRatios does not start with a valid aspectRatio', () => {
it( 'returns the value of AspectRatios.FREE', () => {
const expected = AspectRatios.FREE;
const actual = getDefaultAspectRatio( 'OTHER_INVALID_ASPECT', [ 'INVALID_ASPECT' ] );
expect( actual ).toEqual( expected );
} );
} );
} );
} );
} );
|