From 530b13e8c7b5c66604f9c0e36c2d1174d2369941 Mon Sep 17 00:00:00 2001 From: Nick Taylor Date: Thu, 28 May 2020 11:18:15 -0400 Subject: [PATCH] made all frontend unit tests uniform by preffering it(...) over test(...) (#8113) --- .../onboarding/__tests__/Onboarding.test.jsx | 38 +++++++++---------- .../shared/components/__tests__/tags.test.jsx | 6 +-- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/javascript/onboarding/__tests__/Onboarding.test.jsx b/app/javascript/onboarding/__tests__/Onboarding.test.jsx index d0e6c9325..57d3bfcb5 100644 --- a/app/javascript/onboarding/__tests__/Onboarding.test.jsx +++ b/app/javascript/onboarding/__tests__/Onboarding.test.jsx @@ -139,15 +139,15 @@ describe('', () => { onboardingSlides = initializeSlides(slideIndex, getUserData()); }); - test('renders properly', () => { + it('renders properly', () => { expect(onboardingSlides).toMatchSnapshot(); }); - test('it does not render a stepper', () => { + it('it does not render a stepper', () => { expect(onboardingSlides.find('.stepper').length).toBe(0); }); - test('should advance if required boxes are checked', async () => { + it('should advance if required boxes are checked', async () => { fetch.once({}); expect(onboardingSlides.state().currentSlide).toBe(slideIndex); @@ -162,7 +162,7 @@ describe('', () => { expect(onboardingSlides.state().currentSlide).toBe(slideIndex + 1); }); - test('should not have basic a11y violations', async () => { + it('should not have basic a11y violations', async () => { const results = await axe(onboardingSlides.toString()); expect(results).toHaveNoViolations(); @@ -182,19 +182,19 @@ describe('', () => { await flushPromises(); }); - test('renders properly', () => { + it('renders properly', () => { expect(onboardingSlides).toMatchSnapshot(); }); - test('renders a stepper', () => { + it('renders a stepper', () => { expectStepperToRender(onboardingSlides, slideIndex); }); - test('should render three tags', async () => { + it('should render three tags', async () => { expect(onboardingSlides.find('.onboarding-tags__item').length).toBe(3); }); - test('should allow a user to add a tag and advance', async () => { + it('should allow a user to add a tag and advance', async () => { fetch.once({}); expect(onboardingSlides.find('.next-button').text()).toContain( 'Skip for now', @@ -236,15 +236,15 @@ describe('', () => { onboardingSlides = initializeSlides(slideIndex, getUserData()); }); - test('renders properly', () => { + it('renders properly', () => { expect(onboardingSlides).toMatchSnapshot(); }); - test('renders a stepper', () => { + it('renders a stepper', () => { expectStepperToRender(onboardingSlides, slideIndex); }); - test('should allow user to fill forms and advance', async () => { + it('should allow user to fill forms and advance', async () => { fetch.once({}); const summaryEvent = { target: { value: 'my bio', name: 'summary' } }; const locationEvent = { @@ -310,19 +310,19 @@ describe('', () => { await flushPromises(); }); - test('renders properly', () => { + it('renders properly', () => { expect(onboardingSlides).toMatchSnapshot(); }); - test('renders a stepper', () => { + it('renders a stepper', () => { expectStepperToRender(onboardingSlides, slideIndex); }); - test('should render three users', async () => { + it('should render three users', async () => { expect(onboardingSlides.find('.user').length).toBe(3); }); - test('should allow a user to select and advance', async () => { + it('should allow a user to select and advance', async () => { fetch.once({}); expect(onboardingSlides.find('.next-button').text()).toContain( @@ -349,7 +349,7 @@ describe('', () => { expect(onboardingSlides.state().currentSlide).toBe(slideIndex + 1); }); - test('should have a functioning select-all toggle', async () => { + it('should have a functioning select-all toggle', async () => { fetch.once({}); expect(onboardingSlides.find('button').last().text()).toBe( @@ -383,15 +383,15 @@ describe('', () => { window.location = location; }); - test('renders properly', () => { + it('renders properly', () => { expect(onboardingSlides).toMatchSnapshot(); }); - test('renders a stepper', () => { + it('renders a stepper', () => { expectStepperToRender(onboardingSlides, slideIndex); }); - test('should redirect user when finished', async () => { + it('should redirect user when finished', async () => { fetch.once({}); // Setup: Enable window.location to be writable. diff --git a/app/javascript/shared/components/__tests__/tags.test.jsx b/app/javascript/shared/components/__tests__/tags.test.jsx index 25a9daff6..2dc57274e 100644 --- a/app/javascript/shared/components/__tests__/tags.test.jsx +++ b/app/javascript/shared/components/__tests__/tags.test.jsx @@ -17,7 +17,7 @@ describe('', () => { describe('handleKeyDown', () => { const preventDefaultMock = jest.fn(); - const createKeyDown = key => ({ + const createKeyDown = (key) => ({ key, preventDefault: preventDefaultMock, }); @@ -26,13 +26,13 @@ describe('', () => { preventDefaultMock.mockClear(); }); - test('calls preventDefault on unused keyCode', () => { + it('calls preventDefault on unused keyCode', () => { tags.find('#tag-input').simulate('keydown', createKeyDown('ยง')); tags.find('#tag-input').simulate('keydown', createKeyDown('\\')); expect(preventDefaultMock).toHaveBeenCalledTimes(2); }); - test('does not call preventDefault on used keyCode', () => { + it('does not call preventDefault on used keyCode', () => { tags.find('#tag-input').simulate('keypress', createKeyDown('a')); tags.find('#tag-input').simulate('keydown', createKeyDown('1')); tags.find('#tag-input').simulate('keypress', createKeyDown(','));