import React from 'react'
import { render, screen } from '../utilities/test-utils'
import Contact from './_contact'
test('returns namespaced class name', () => {
render(
)
const kit = screen.getByTestId('class-name-test')
expect(kit).toHaveClass('pb_contact_kit')
})
test('returns correct icon', () => {
render(
<>
>
)
expect(screen.getByTestId('test-cell').querySelector('.pb_icon_kit')).toHaveClass('fa-mobile')
expect(screen.getByTestId('test-home').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
expect(screen.getByTestId('test-work').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-office')
expect(screen.getByTestId('test-work-cell').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-laptop')
expect(screen.getByTestId('test-email').querySelector('.pb_custom_icon')).toHaveClass('envelope')
expect(screen.getByTestId('test-wrong-phone').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-slash')
expect(screen.getByTestId('test-wrong-type').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
expect(screen.getByTestId('test-extension').querySelector('.pb_icon_kit')).toHaveClass('fa-phone-plus')
expect(screen.getByTestId('test-empty').querySelector('.pb_icon_kit')).toHaveClass('fa-phone')
})
test("not compliant values return null in phone related contact types", () => {
const notCompliantValues = [
"349-185-998223",
"349-1858",
"",
"2",
"string",
]
const contactTypes = [
"cell",
"work",
"work-cell",
"wrong-number",
"wrong-phone",
"wrong-type",
"extension",
]
const buildData = contactTypes.reduce((response, type) => {
notCompliantValues.forEach((value) => response.push({ type, value }))
return response
}, [])
const { rerender } = render(
)
buildData.map(({ type, value }) => {
rerender(
)
expect(screen.getByTestId("contact-kit-null-test")).toHaveTextContent(
"null"
)
})
})