Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(baseurl): add tests
  • Loading branch information
danilowoz committed Mar 7, 2019
commit 92e181f08a94f0aeebadaaddce22e7f59f239196
28 changes: 19 additions & 9 deletions src/__tests__/Holder.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@ describe('Holder', () => {
const withPropsComponent = ShallowRenderer.createRenderer()
withPropsComponent.render(
<ContentLoader
rtl
speed={10}
interval={0.5}
width={200}
animate={false}
ariaLabel="My custom loading title"
baseUrl="/mypage"
className="random-className"
gradientRatio={0.5}
height={200}
animate={false}
interval={0.5}
preserveAspectRatio="xMaxYMax meet"
primaryColor="#000"
secondaryColor="#fff"
primaryOpacity={0.06}
rtl
secondaryColor="#fff"
secondaryOpacity={0.12}
preserveAspectRatio="xMaxYMax meet"
className="random-className"
speed={10}
style={{ marginBottom: '10px' }}
ariaLabel="My custom loading title"
width={200}
/>
)

Expand Down Expand Up @@ -174,5 +175,14 @@ describe('Holder', () => {
expect(typeof propsFromFullfield.ariaLabel).toBe('string')
expect(propsFromFullfield.ariaLabel).toBe('My custom loading title')
})

it("`baseUrl` is a string and it's used", () => {
// defaultProps
expect(typeof propsFromEmpty.baseUrl).toBe('string')
expect(propsFromEmpty.baseUrl).toBe('')
// custom props
expect(typeof propsFromFullfield.baseUrl).toBe('string')
expect(propsFromFullfield.baseUrl).toBe('/mypage')
})
})
})
16 changes: 16 additions & 0 deletions src/__tests__/Svg.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ describe('Svg', () => {
title: wrapper.findByType('title'),
}

it('baseUrl is used correctly', () => {
const baseUrl = '/page-path'
const wrapperWithBaseUrl = renderer.create(<Svg baseUrl={baseUrl} />).root

const clipPath = wrapperWithBaseUrl.findByType('clipPath')
const linearGradient = wrapperWithBaseUrl.findByType('linearGradient')
const rectClipPath = wrapperWithBaseUrl.find(predicateRectClipPath)

expect(rectClipPath.props.clipPath).toBe(
`url(${baseUrl}#${clipPath.props.id})`
)
expect(rectClipPath.props.style.fill).toBe(
`url(${baseUrl}#${linearGradient.props.id})`
)
})

describe('it has basic elements necessary to work ', () => {
it('has a `rect` with `clipPath`', () => {
const { allRectClipPath } = partsOfComponent
Expand Down