-
-
Save dmitryshelomanov/6eb8c7cdf6277cb1b6b8967959f967b6 to your computer and use it in GitHub Desktop.
test molecules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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