Fix timestamps/spellcheck to use locale override

This commit is contained in:
Jamie Kyle 2023-11-06 17:02:13 -08:00 committed by GitHub
parent 59fa75c309
commit fd8691b871
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 45 additions and 11 deletions

View file

@ -12,6 +12,7 @@ const max = new Date(2023, 0, 1, 23).getTime();
describe('formatTimestamp', () => {
let sandbox: sinon.SinonSandbox;
let localesStub: sinon.SinonStub;
let localeOverrideStub: sinon.SinonStub;
let hourCycleStub: sinon.SinonStub;
beforeEach(() => {
@ -20,6 +21,10 @@ describe('formatTimestamp', () => {
window.SignalContext,
'getPreferredSystemLocales'
);
localeOverrideStub = sandbox.stub(
window.SignalContext,
'getLocaleOverride'
);
hourCycleStub = sandbox.stub(
window.SignalContext,
'getHourCyclePreference'
@ -41,6 +46,7 @@ describe('formatTimestamp', () => {
}).format(time);
it(`should format with locale: ${locale} (${HourCyclePreference[preference]}) @ ${timeFmt})`, () => {
localesStub.returns([locale]);
localeOverrideStub.returns(null);
hourCycleStub.returns(preference);
assert.equal(formatTimestamp(time, { timeStyle: 'medium' }), expected);
});