From 972efe26b4938ef32df4e375a3dad80e14a2fb83 Mon Sep 17 00:00:00 2001 From: Alisher Musurmonov Date: Wed, 25 Sep 2024 10:20:07 +0500 Subject: [PATCH] refactor: fix code quality based on comments --- .../AffiliationsSelection.test.js | 2 +- .../FieldLocationFinalContainer.test.js | 16 ++++++++++------ lib/LanguageFilter/LanguageFilter.test.js | 1 - 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/AffiliationsSelection/AffiliationsSelection.test.js b/lib/AffiliationsSelection/AffiliationsSelection.test.js index 3318f3ce..e2175546 100644 --- a/lib/AffiliationsSelection/AffiliationsSelection.test.js +++ b/lib/AffiliationsSelection/AffiliationsSelection.test.js @@ -36,7 +36,7 @@ const renderAffiliationsSelection = (props = {}) => render( ); describe('AffiliationsSelection', () => { - it('should render affiliation selection with provided options', async () => { + it('should render affiliation selection with provided options', () => { renderAffiliationsSelection(); expect( diff --git a/lib/FieldLocation/FieldLocationFinalContainer.test.js b/lib/FieldLocation/FieldLocationFinalContainer.test.js index 725add2d..3b80b458 100644 --- a/lib/FieldLocation/FieldLocationFinalContainer.test.js +++ b/lib/FieldLocation/FieldLocationFinalContainer.test.js @@ -32,16 +32,12 @@ const renderFieldLocationFinalContainer = (props = {}, formProps = {}) => (rende )); describe('FieldLocationFinalContainer component', () => { - beforeEach(() => { - renderFieldLocationFinalContainer(); + it('should display passed label', () => { + renderFieldLocationFinalContainer({ labelId: 'Location' }); const button = screen.getByText('stripes-components.selection.controlLabel'); fireEvent.click(button); - }); - - it('should display passed label', () => { - renderFieldLocationFinalContainer({ labelId: 'Location' }); expect(screen.getByText(fieldLocationLabel)).toBeDefined(); }); @@ -49,6 +45,10 @@ describe('FieldLocationFinalContainer component', () => { it('should render options based on passed locationIds', async () => { renderFieldLocationFinalContainer(); + const button = screen.getByText('stripes-components.selection.controlLabel'); + + fireEvent.click(button); + const renderedLocationOptions = await screen.findAllByText(/Location #[0-9]/); expect(renderedLocationOptions.length).toBe(locationsIds.length); @@ -59,6 +59,10 @@ describe('FieldLocationFinalContainer component', () => { filterLocations: (records) => records.slice(0, 2), }); + const button = screen.getByText('stripes-components.selection.controlLabel'); + + fireEvent.click(button); + const renderedLocationOptions = await screen.findAllByText(/Location #[0-9]/); expect(renderedLocationOptions).toHaveLength(2); diff --git a/lib/LanguageFilter/LanguageFilter.test.js b/lib/LanguageFilter/LanguageFilter.test.js index adf6ff6b..a9f3acfb 100644 --- a/lib/LanguageFilter/LanguageFilter.test.js +++ b/lib/LanguageFilter/LanguageFilter.test.js @@ -1,5 +1,4 @@ import { - cleanup, fireEvent, render, } from '@testing-library/react';