Skip to content

Instantly share code, notes, and snippets.

@dmitryshelomanov
Created December 25, 2017 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitryshelomanov/6eb8c7cdf6277cb1b6b8967959f967b6 to your computer and use it in GitHub Desktop.
Save dmitryshelomanov/6eb8c7cdf6277cb1b6b8967959f967b6 to your computer and use it in GitHub Desktop.
test molecules
let props
let withInfo
let withoutInfo
beforeEach(() => {
withInfo = {
url: 'path_to_image',
info: {
percentCompress: 0,
},
}
withoutInfo = {
url: 'path_to_image',
info: null,
}
props = (info = true) => ({
activeImage: 1,
ids: 0,
width: '240px',
img: info ? withInfo : withoutInfo,
})
})
describe('test component CarouselItem', () => {
it('CarouselItem render without crash', () => {
render(<CarouselItem {...props()} />)
})
it('CarouselItem render with info', () => {
const wrapper = shallow(<CarouselItem {...props()} />)
const { img } = wrapper.instance().props
expect(img).toBe(withInfo)
})
it('CarouselItem render without info', () => {
const wrapper = shallow(<CarouselItem {...props(false)} />)
const { img } = wrapper.instance().props
expect(img).toBe(withoutInfo)
})
it('CarouselItem props is equals', () => {
const data = props(false)
const wrapper = shallow(<CarouselItem {...data} />)
const { img, activeImage, width, ids } = wrapper.instance().props
expect(img).toBe(data.img)
expect(activeImage).toBe(data.activeImage)
expect(width).toBe(data.width)
expect(ids).toBe(data.ids)
})
it('shapshot Button', () => {
const tree = create(<CarouselItem {...props()} />)
.toJSON()
expect(tree).toMatchSnapshot()
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment