FrontendAtlas
Study
▾
Dashboard
Pricing
Get full access
</> Code
Test cases
Language
JavaScript
TypeScript
export default function formatDateInTimeZone(date, timeZone) { throw new Error('Not implemented'); }
import formatDateInTimeZone from './formatDateInTimeZone'; describe('formatDateInTimeZone', () => { test('formats date in different time zones', () => { const date = new Date('2020-01-01T00:30:00Z'); expect(formatDateInTimeZone(date, 'America/Los_Angeles')).toBe('2019-12-31'); expect(formatDateInTimeZone(date, 'Asia/Tokyo')).toBe('2020-01-01'); }); test('accepts a timestamp', () => { const ts = Date.parse('2020-07-01T23:30:00Z'); expect(formatDateInTimeZone(ts, 'UTC')).toBe('2020-07-01'); }); test('throws on invalid date', () => { expect(() => formatDateInTimeZone(new Date('invalid'), 'UTC')).toThrow(); }); });
▶ Run tests
Results
Console
Run tests to see results.