import React from 'react' import { mount } from 'enzyme' import { Item } from '../_internals/item/Item' import { Avatar } from '../avatar' import { Profile } from '../profile' import { TextDisplayType } from '../text' import { TextBody } from '../typography/body' import { Rating } from './rating' const defaultProps = { mainTitle: 'Jack Sparrow', } describe('Profile default', () => { let defaultProfile: any beforeEach(() => { defaultProfile = mount() }) it('Should pass a title prop to Item', () => { expect(defaultProfile.find(Item).prop('leftTitle')).toEqual('Jack Sparrow') }) it("Shouldn't have `aria-label` by default", () => { expect(defaultProfile.find(Item).prop('aria-label')).toBeFalsy() }) it('Should change the leftTitleDisplay prop if isMedium', () => { expect(defaultProfile.find(Item).prop('leftTitleDisplay')).toEqual(TextDisplayType.TITLE) const profileMedium = mount() expect(profileMedium.find(Item).prop('leftTitleDisplay')).toEqual(TextDisplayType.DISPLAY1) }) it('Should not have a chevron by default', () => { expect(defaultProfile.find(Item).prop('chevron')).toBe(false) }) }) describe('Profile', () => { it('Should have `aria-label`', () => { const profile = mount() expect(profile.find(Item).prop('aria-label')).toEqual('testLabel') }) it('Should display info if no rating is provided', () => { const profile = mount() expect(profile.find(Item).find(TextBody).text()).toEqual('test label') }) it('Should display the rating over info if both are provided', () => { const profile = mount() const rating = profile.find(Item).find(Rating) expect(rating.exists()).toBeTruthy() expect(rating.exists()).toBeTruthy() expect(rating.prop('ratings')).toBe(2) }) it('Should pass a rightAddon prop to Item', () => { const pictureUrl = 'https://s3.amazonaws.com/37assets/svn/1065-IMG_2529.jpg' const profile = mount() const avatar = profile.find(Item).find(Avatar) expect(avatar.exists()).toBeTruthy() expect(avatar.prop('image')).toBe(pictureUrl) }) it('Should pass all picture props to Avatar', () => { const pictureUrl = 'https://s3.amazonaws.com/37assets/svn/1065-IMG_2529.jpg' const profile = mount( , ) const avatar = profile.find(Item).find(Avatar) expect(avatar.exists()).toBeTruthy() expect(avatar.prop('image')).toBe(pictureUrl) expect(avatar.prop('alt')).toBe('alt_text') expect(avatar.prop('isMedium')).toBe(true) expect(avatar.prop('isIdChecked')).toBe(true) }) it('Should pass a chevron prop to Item when isLink is true', () => { const profile = mount() expect(profile.find(Item).prop('chevron')).toBe(true) }) it('Should pass a chevron prop to Item when href is present', () => { const profile = mount() expect(profile.find(Item).prop('chevron')).toBe(true) }) it('Should pass a chevron prop to Item when href is present', () => { const profile = mount( null} />) expect(profile.find(Item).prop('chevron')).toBe(true) }) })