import React from 'react'
import { render, screen } from '../utilities/test-utils'
import { Passphrase } from '../'
const testId = 'text-input1',
kitClass = 'pb_passphrase'
/* See these resources for more testing info:
- https://github.com/testing-library/jest-dom#usage for useage and examples
- https://jestjs.io/docs/en/using-matchers
*/
test('returns namespaced class name', () => {
render(
)
const kit = screen.getByTestId(testId)
expect(kit).toHaveClass(kitClass)
})
test('returns additional class name', () => {
render(
)
const kit = screen.getByTestId(testId)
expect(kit).toHaveClass(`${kitClass} additional_class`)
})
test('returns dark class name', () => {
render(
)
const kit = screen.getByTestId(testId)
expect(kit).toHaveClass(`${kitClass} dark`)
})
test('passes input props to input element', () => {
render(
)
const kit = screen.getByTestId(testId)
const input = kit.getElementsByTagName('input')[0]
expect(input).toHaveAttribute('name', 'test-name')
expect(input).toHaveAttribute('id', 'test-input-id')
expect(input).toBeDisabled()
})
test('progress bar is invisible when value is empty', () => {
render(
)
const kit = screen.getByTestId(testId)
expect(kit.querySelector('[class^=pb_progress_simple_wrapper]')).toHaveClass('progress-empty-input')
})
test('progress bar is visible when value is not empty', () => {
render(
)
const kit = screen.getByTestId(testId)
expect(kit.querySelector('[class^=pb_progress_simple_wrapper]')).not.toHaveClass('progress-empty-input')
})
test('no progress bar is show when confirmation is true', () => {
render(
)
const kit = screen.getByTestId(testId)
expect(kit.querySelector('[class^=pb_progress_simple_wrapper]')).toBeNull()
})
test('popover target shows when tips are given', () => {
render(
)
const kit = screen.getByTestId(testId)
expect(kit.querySelector('[class^=pb_popover_reference_wrapper]')).toBeDefined()
})
test('popover target does not show when tips are not given', () => {
render(
)
const kit = screen.getByTestId(testId)
expect(kit.querySelector('[class^=pb_popover_reference_wrapper]')).toBeNull()
})