diff options
Diffstat (limited to 'plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test')
5 files changed, 176 insertions, 0 deletions
diff --git a/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/__snapshots__/index.js.snap b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/__snapshots__/index.js.snap new file mode 100644 index 00000000..e726fa52 --- /dev/null +++ b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/__snapshots__/index.js.snap @@ -0,0 +1,98 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders as expected 1`] = ` +<Gallery + galleryRef={ + Object { + "current": null, + } + } +> + <Row + key="0" + > + <Column + key="0" + > + 0 + </Column> + </Row> + <Row + key="1" + > + <Column + key="0" + > + 1 + </Column> + </Row> + <Row + key="2" + > + <Column + key="0" + > + 2 + </Column> + <Column + key="1" + > + 3 + </Column> + <Column + key="2" + > + 4 + </Column> + <Column + key="3" + > + 5 + </Column> + </Row> + <Row + key="3" + > + <Column + key="0" + > + 6 + </Column> + <Column + key="1" + > + 7 + </Column> + </Row> + <Row + key="4" + > + <Column + key="0" + > + 8 + </Column> + <Column + key="1" + > + 9 + 10 + </Column> + </Row> + <Row + key="5" + > + <Column + key="0" + > + 11 + 12 + </Column> + <Column + key="1" + > + 13 + </Column> + </Row> +</Gallery> +`; diff --git a/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/__snapshots__/ratios.js.snap b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/__snapshots__/ratios.js.snap new file mode 100644 index 00000000..df02118c --- /dev/null +++ b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/__snapshots__/ratios.js.snap @@ -0,0 +1,30 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ratiosToMosaicRows transforms as expected 1`] = ` +Array [ + Array [ + 1, + ], + Array [ + 1, + ], + Array [ + 1, + 1, + 1, + 1, + ], + Array [ + 1, + 1, + ], + Array [ + 1, + 2, + ], + Array [ + 2, + 1, + ], +] +`; diff --git a/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/fixtures/ratios.js b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/fixtures/ratios.js new file mode 100644 index 00000000..77db288c --- /dev/null +++ b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/fixtures/ratios.js @@ -0,0 +1,16 @@ +export const ratios = [ + 4, + 2.26056338028169, + 0.6676143094053542, + 0.75, + 0.7444409646100846, + 0.6666666666666666, + 0.8000588062334607, + 3.6392174704276616, + 1.335559265442404, + 1.509433962264151, + 1.6, + 1.3208430913348945, + 1.3553937789543349, + 1.499531396438613, +]; diff --git a/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/index.js b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/index.js new file mode 100644 index 00000000..72e49ba6 --- /dev/null +++ b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/index.js @@ -0,0 +1,21 @@ +/** + * External dependencies + */ +import React from 'react'; +import { range } from 'lodash'; +import { shallow } from 'enzyme'; + +/** + * Internal dependencies + */ +import Mosaic from '..'; +import * as imageSets from '../../test/fixtures/image-sets'; + +test( 'renders as expected', () => { + Object.keys( imageSets ).forEach( k => { + const images = imageSets[ k ]; + expect( + shallow( <Mosaic images={ images } renderedImages={ range( images.length ) } /> ) + ).toMatchSnapshot(); + } ); +} ); diff --git a/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/ratios.js b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/ratios.js new file mode 100644 index 00000000..3756b971 --- /dev/null +++ b/plugins/jetpack/extensions/blocks/tiled-gallery/layout/mosaic/test/ratios.js @@ -0,0 +1,11 @@ +/** + * Internal dependencies + */ +import { ratiosToMosaicRows } from '../ratios'; +import { ratios } from './fixtures/ratios'; + +describe( 'ratiosToMosaicRows', () => { + test( 'transforms as expected', () => { + expect( ratiosToMosaicRows( ratios ) ).toMatchSnapshot(); + } ); +} ); |