Added uniquekey a defaultProp (#81)

This commit is contained in:
Nic Mitchell
2018-02-03 07:25:04 -08:00
committed by Danilo Woznica
parent 61bd3aae6d
commit 6669f0304e
3 changed files with 11 additions and 3 deletions

View File

@@ -1,6 +1,5 @@
//@flow
import * as React from 'react'
import uid from './uid'
import type { Props as ContentLoaderProps } from './index'
@@ -9,8 +8,8 @@ export type WrapProps = {
} & ContentLoaderProps
const Wrap = (props: WrapProps): React.Element<*> => {
const idClip = `${props.uniquekey}-idClip` || uid()
const idGradient = `${props.uniquekey}-idGradient` || uid()
const idClip = `${props.uniquekey}-idClip`
const idGradient = `${props.uniquekey}-idGradient`
return (
<svg

View File

@@ -1,6 +1,7 @@
//@flow
import * as React from 'react'
import Wrap from './Wrap'
import uid from './uid'
// Stylized
export { default as Facebook } from './stylized/FacebookStyle'
@@ -29,6 +30,7 @@ const defaultProps = {
primaryColor: '#f0f0f0',
secondaryColor: '#e0e0e0',
preserveAspectRatio: 'xMidYMid meet',
uniquekey: uid(),
}
const InitialComponent = props => (

View File

@@ -71,5 +71,12 @@ describe('<ContentLoader />:', () => {
it('`style` is a object and used', () => {
expect(wrapper.props().style).to.deep.equal({ marginBottom: '10px' })
})
it('`uniquekey` does not generate undefined `id` values for svg', () => {
const idClip = wrapper.find('clipPath').prop('id')
const idGradient = wrapper.find('linearGradient').prop('id')
expect(idClip).to.not.contain(undefined)
expect(idGradient).to.not.contain(undefined)
})
})
})