From 50bfa05a4f87e0086ea02b953b88ef8e16cb2d5e Mon Sep 17 00:00:00 2001 From: Trevor Lang Date: Fri, 13 Oct 2023 09:04:45 -0600 Subject: [PATCH] EDD-31: PR feedback --- .../DownloadListItemFileProgress.module.scss | 2 +- .../dialogs/MoreErrorInfo/MoreErrorInfo.jsx | 7 ++---- .../__tests__/MoreErrorInfo.test.js | 22 +++++++++++++---- .../utils/__tests__/humanizeDuration.test.js | 24 +++++++++---------- src/app/utils/humanizeDuration.js | 4 ++-- 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/app/components/DownloadListItem/DownloadListItemFileProgress.module.scss b/src/app/components/DownloadListItem/DownloadListItemFileProgress.module.scss index 1d24a6ba..74fa90ce 100644 --- a/src/app/components/DownloadListItem/DownloadListItemFileProgress.module.scss +++ b/src/app/components/DownloadListItem/DownloadListItemFileProgress.module.scss @@ -37,4 +37,4 @@ &:hover { color: var(--color__black--700); } -} \ No newline at end of file +} diff --git a/src/app/dialogs/MoreErrorInfo/MoreErrorInfo.jsx b/src/app/dialogs/MoreErrorInfo/MoreErrorInfo.jsx index 1bf242d7..830eaf14 100644 --- a/src/app/dialogs/MoreErrorInfo/MoreErrorInfo.jsx +++ b/src/app/dialogs/MoreErrorInfo/MoreErrorInfo.jsx @@ -87,11 +87,8 @@ const MoreErrorInfo = ({ <>

- {`${numberErrors} ${pluralize('file', numberErrors)} `} - were not able to be downloaded. If the problem persists, - {' '} - try initializing the download again to download your files. - {' '} + {`${numberErrors} ${pluralize('file', numberErrors)} ${numberErrors > 1 ? 'were' : 'was'} not able to be downloaded. `} + {`If the problem persists, try initializing the download again to download your ${pluralize('file', numberErrors)}.`}

diff --git a/src/app/dialogs/MoreErrorInfo/__tests__/MoreErrorInfo.test.js b/src/app/dialogs/MoreErrorInfo/__tests__/MoreErrorInfo.test.js index 8b0e0717..80ba99c7 100644 --- a/src/app/dialogs/MoreErrorInfo/__tests__/MoreErrorInfo.test.js +++ b/src/app/dialogs/MoreErrorInfo/__tests__/MoreErrorInfo.test.js @@ -73,12 +73,26 @@ describe('MoreErrorInfo component', () => { }) describe('when the state is not errorFetchingLinks', () => { - test('displays the error message and button to the files', () => { - setup() + describe('when a single error exists', () => { + test('displays the error message and button to the files', () => { + setup({ + numberErrors: 1 + }) - expect(screen.getByText('3 files were not able to be downloaded. If the problem persists, try initializing the download again to download your files.')).toBeInTheDocument() + expect(screen.getByText('1 file was not able to be downloaded. If the problem persists, try initializing the download again to download your file.')).toBeInTheDocument() - expect(screen.getByRole('button', { name: 'View Download' })).toBeInTheDocument() + expect(screen.getByRole('button', { name: 'View Download' })).toBeInTheDocument() + }) + }) + + describe('when multiple exists', () => { + test('displays the error message and button to the files', () => { + setup() + + expect(screen.getByText('3 files were not able to be downloaded. If the problem persists, try initializing the download again to download your files.')).toBeInTheDocument() + + expect(screen.getByRole('button', { name: 'View Download' })).toBeInTheDocument() + }) }) test('clicking the downloadId button calls setCurrentPage, setSelectedDownloadId and closes the dialog', async () => { diff --git a/src/app/utils/__tests__/humanizeDuration.test.js b/src/app/utils/__tests__/humanizeDuration.test.js index eb2aab41..f29bc56b 100644 --- a/src/app/utils/__tests__/humanizeDuration.test.js +++ b/src/app/utils/__tests__/humanizeDuration.test.js @@ -16,9 +16,9 @@ describe('humanizeDuration', () => { expect.objectContaining({ largest: 2, round: 1, - language: 'shortEn', + language: 'abbreviatedEnglish', languages: { - shortEn: expect.objectContaining({ + abbreviatedEnglish: expect.objectContaining({ y: expect.any(Function), mo: expect.any(Function), w: expect.any(Function), @@ -35,18 +35,18 @@ describe('humanizeDuration', () => { ) }) - test('the functions that define the custom shortEn language return the correct values', () => { + test('the functions that define the custom abbreviatedEnglish language return the correct values', () => { humanizeDuration(1234) - const shortEnConfig = hd.mock.calls[0][1].languages.shortEn + const abbreviatedEnglishConfig = hd.mock.calls[0][1].languages.abbreviatedEnglish - expect(shortEnConfig.y()).toEqual('y') - expect(shortEnConfig.mo()).toEqual('mo') - expect(shortEnConfig.w()).toEqual('w') - expect(shortEnConfig.d()).toEqual('d') - expect(shortEnConfig.h()).toEqual('h') - expect(shortEnConfig.m()).toEqual('m') - expect(shortEnConfig.s()).toEqual('s') - expect(shortEnConfig.ms()).toEqual('ms') + expect(abbreviatedEnglishConfig.y()).toEqual('y') + expect(abbreviatedEnglishConfig.mo()).toEqual('mo') + expect(abbreviatedEnglishConfig.w()).toEqual('w') + expect(abbreviatedEnglishConfig.d()).toEqual('d') + expect(abbreviatedEnglishConfig.h()).toEqual('h') + expect(abbreviatedEnglishConfig.m()).toEqual('m') + expect(abbreviatedEnglishConfig.s()).toEqual('s') + expect(abbreviatedEnglishConfig.ms()).toEqual('ms') }) }) diff --git a/src/app/utils/humanizeDuration.js b/src/app/utils/humanizeDuration.js index 4beb5787..b51b6c56 100644 --- a/src/app/utils/humanizeDuration.js +++ b/src/app/utils/humanizeDuration.js @@ -8,9 +8,9 @@ import hd from 'humanize-duration' export const humanizeDuration = (duration) => hd(duration, { largest: 2, round: 1, - language: 'shortEn', + language: 'abbreviatedEnglish', languages: { - shortEn: { + abbreviatedEnglish: { y: () => 'y', mo: () => 'mo', w: () => 'w',