Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
fixes conditionfield test randomly failing
Browse files Browse the repository at this point in the history
  • Loading branch information
tinkertrain committed May 25, 2021
1 parent 5365571 commit d84f9b2
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions src/components/ConditionField/ConditionField.test.js
Expand Up @@ -81,6 +81,12 @@ describe('Tooltip', () => {

describe('With selectable conjunction', () => {
test('should display selectable conjunction button with AND/OR options', async () => {
const dropdownTrigger = () =>
screen.queryByRole('button', {
name: 'toggle menu',
})

const conjunctionMenu = () => screen.getByRole('listbox')
render(
<ConditionField.Group canChangeConjunction>
<ConditionField />
Expand All @@ -102,6 +108,11 @@ describe('With selectable conjunction', () => {
})

test('should display OR selected when no conjunction provided', async () => {
const dropdownTrigger = () =>
screen.queryByRole('button', {
name: 'toggle menu',
})

render(
<ConditionField.Group canChangeConjunction>
<ConditionField />
Expand All @@ -116,6 +127,12 @@ describe('With selectable conjunction', () => {
})

test('should mark provided item as selected', async () => {
const dropdownTrigger = () =>
screen.queryByRole('button', {
name: 'toggle menu',
})

const conjunctionMenu = () => screen.getByRole('listbox')
render(
<ConditionField.Group canChangeConjunction conjunction={'and'}>
<ConditionField />
Expand All @@ -134,6 +151,12 @@ describe('With selectable conjunction', () => {
})

test('should make a callback when conjunction changed', async () => {
const dropdownTrigger = () =>
screen.queryByRole('button', {
name: 'toggle menu',
})

const conjunctionMenu = () => screen.getByRole('listbox')
const mock = jest.fn()
render(
<ConditionField.Group canChangeConjunction onConjunctionChange={mock}>
Expand Down Expand Up @@ -174,6 +197,11 @@ describe('With selectable conjunction', () => {
})

test('should disable button to add, but not switch', () => {
const dropdownTrigger = () =>
screen.queryByRole('button', {
name: 'toggle menu',
})

render(
<ConditionField.Group canChangeConjunction isAddEnabled={false}>
<ConditionField />
Expand All @@ -186,6 +214,11 @@ describe('With selectable conjunction', () => {
})

test('should not display dropdown when flag is set to false', () => {
const dropdownTrigger = () =>
screen.queryByRole('button', {
name: 'toggle menu',
})

render(
<ConditionField.Group canChangeConjunction={false}>
<ConditionField />
Expand All @@ -197,13 +230,6 @@ describe('With selectable conjunction', () => {
expect(screen.getByRole('button', { name: 'or' })).toBeInTheDocument()
})

const dropdownTrigger = () =>
screen.queryByRole('button', {
name: 'toggle menu',
})

const conjunctionMenu = () => screen.getByRole('listbox')

function getOrConjunctions(container) {
return container.querySelectorAll('.c-ConditionOperator.is-or')
}
Expand Down

0 comments on commit d84f9b2

Please sign in to comment.