Commit 4564d5d6 authored by Robert Knight's avatar Robert Knight

Fix formatDate test failing due to space char mismatch

The `formatDate` test failed for me locally due to Chrome using a "\u202F"
(Narrow non-breaking space) char between "11:02" and "PM", instead of a regular
space. Apply unicode normalization to ignore this difference.
parent 782ae256
...@@ -229,6 +229,11 @@ describe('sidebar/util/time', () => { ...@@ -229,6 +229,11 @@ describe('sidebar/util/time', () => {
}); });
describe('formatDate', () => { describe('formatDate', () => {
// Normalize "special" spaces (eg. "\u202F") to standard spaces.
function normalizeSpaces(str) {
return str.normalize('NFKC');
}
it('returns absolute formatted date', () => { it('returns absolute formatted date', () => {
const date = new Date('2020-05-04T23:02:01'); const date = new Date('2020-05-04T23:02:01');
const fakeIntl = locale => ({ const fakeIntl = locale => ({
...@@ -238,14 +243,14 @@ describe('sidebar/util/time', () => { ...@@ -238,14 +243,14 @@ describe('sidebar/util/time', () => {
}); });
assert.equal( assert.equal(
formatDate(date, fakeIntl('en-US')), normalizeSpaces(formatDate(date, fakeIntl('en-US'))),
'Monday, May 04, 2020, 11:02 PM' 'Monday, May 04, 2020, 11:02 PM'
); );
clearFormatters(); clearFormatters();
assert.equal( assert.equal(
formatDate(date, fakeIntl('de-DE')), normalizeSpaces(formatDate(date, fakeIntl('de-DE'))),
'Montag, 04. Mai 2020, 23:02' 'Montag, 04. Mai 2020, 23:02'
); );
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment