Skip to content

Commit

Permalink
EDD-31: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorlang authored and macrouch committed Oct 13, 2023
1 parent 8c0b50b commit 50bfa05
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
&:hover {
color: var(--color__black--700);
}
}
}
7 changes: 2 additions & 5 deletions src/app/dialogs/MoreErrorInfo/MoreErrorInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,8 @@ const MoreErrorInfo = ({
<>
<div className={styles.message}>
<p>
{`${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)}.`}
</p>
</div>
<div className={styles.actions}>
Expand Down
22 changes: 18 additions & 4 deletions src/app/dialogs/MoreErrorInfo/__tests__/MoreErrorInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
24 changes: 12 additions & 12 deletions src/app/utils/__tests__/humanizeDuration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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')
})
})
4 changes: 2 additions & 2 deletions src/app/utils/humanizeDuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 50bfa05

Please sign in to comment.