diff --git a/src/components/Image/__tests__/index-test.js b/src/components/Image/__tests__/index-test.js index 63789762..996f4f4d 100644 --- a/src/components/Image/__tests__/index-test.js +++ b/src/components/Image/__tests__/index-test.js @@ -3,9 +3,12 @@ import * as utils from '../../../modules/specHelpers' import assert from 'assert' import React from 'react' +import flattenStyle from '../../../apis/StyleSheet/flattenStyle' import Image from '../' +const getStyleBackgroundSize = (element) => flattenStyle(element.props.style).backgroundSize + suite('components/Image', () => { test('default accessibility', () => { const dom = utils.renderToDOM() @@ -61,10 +64,47 @@ suite('components/Image', () => { test('prop "onLoadStart"') - test('prop "resizeMode"') + suite('prop "resizeMode"', () => { + test('value "contain"', () => { + const result = utils.shallowRender() + assert.equal(getStyleBackgroundSize(result), 'contain') + }) + + test('value "cover"', () => { + const result = utils.shallowRender() + assert.equal(getStyleBackgroundSize(result), 'cover') + }) + + test('value "none"', () => { + const result = utils.shallowRender() + assert.equal(getStyleBackgroundSize(result), 'auto') + }) + + test('value "stretch"', () => { + const result = utils.shallowRender() + assert.equal(getStyleBackgroundSize(result), '100% 100%') + }) + + test('no value', () => { + const result = utils.shallowRender() + assert.equal(getStyleBackgroundSize(result), 'cover') + }) + }) test('prop "source"') + suite('prop "style"', () => { + test('converts "resizeMode" property', () => { + const result = utils.shallowRender() + assert.equal(getStyleBackgroundSize(result), 'contain') + }) + + test('removes "resizeMode" property', () => { + const result = utils.shallowRender() + assert.equal(flattenStyle(result.props.style).resizeMode, undefined) + }) + }) + test('prop "testID"', () => { const testID = 'testID' const result = utils.shallowRender()