Skip to content

Commit

Permalink
Use Narrow No-Break Space in expected date format results
Browse files Browse the repository at this point in the history
Apparently, Intl.DateTimeFormat now uses "Narrow No-Break Space"
before the AM and PM suffices, instead of a regular space.

This commit updates the tests to account for this change.
  • Loading branch information
csillag committed Nov 12, 2022
1 parent 688b7df commit 5ac2a7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/app/components/DateFormatter/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ import { render, screen } from '@testing-library/react'
import { intlDateTimeFormat, DateFormatter } from '..'
import { buildDatetime } from '../../../../../internals/getBuildData'

/**
* Narrow No-Brake Space
*
* This is used by the date formatter.
* See https://unicodeplus.com/U+202F
*/
const NNBSP = '\u202F'

describe('intlDateTimeFormat', () => {
it('should format date to human readable format', () => {
expect(intlDateTimeFormat(1656932251000)).toEqual('7/4/2022, 10:57:31 AM')
expect(intlDateTimeFormat(new Date(Date.UTC(2022, 6, 27, 8, 33, 10)))).toEqual('7/27/2022, 8:33:10 AM')
expect(intlDateTimeFormat(1656932251000)).toEqual(`7/4/2022, 10:57:31${NNBSP}AM`)
expect(intlDateTimeFormat(new Date(Date.UTC(2022, 6, 27, 8, 33, 10)))).toEqual(
`7/27/2022, 8:33:10${NNBSP}AM`,
)
})
it('build time should be in the same format as a tested timestamp', () => {
expect(Number(buildDatetime)).toBeCloseTo(1656932251000, -12) // Less than 16 years difference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ exports[`<Footer /> should render mobile version of footer 1`] = `
>
sha0000
</a>
built at 1/1/1970, 12:00:00 AM
built at 1/1/1970, 12:00:00AM
<div
class="c4"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ exports[`<Transaction /> should handle unknown transaction types gracefully 1`]
<span
class="c14"
>
4/10/2021, 1:30:55 AM
4/10/2021, 1:30:55AM
</span>
</div>
</div>
Expand Down Expand Up @@ -1251,7 +1251,7 @@ exports[`<Transaction /> should match snapshot 1`] = `
<span
class="c14"
>
4/10/2021, 1:30:55 AM
4/10/2021, 1:30:55AM
</span>
</div>
</div>
Expand Down

0 comments on commit 5ac2a7e

Please sign in to comment.