Files
klz-cables.com/.pnpm-store/v10/files/da/febe6f785971c6497bcd65a31b6fdeb80a4cbd942890f831dc410cde22034d2e0e46c705f5dc0853e9a793871fe909a25a27eff3507b8a40a99f7cbb4dd025
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

142 lines
4.0 KiB
Plaintext

import { describe, expect, it } from 'vitest';
import { formatUtcOffset } from './formatUtcOffset.js';
describe('formatUtcOffset', ()=>{
describe('valid UTC offsets', ()=>{
it.each([
[
'+00:00',
'_TZOFFSET_PLUS_00_00'
],
[
'+05:30',
'_TZOFFSET_PLUS_05_30'
],
[
'+05:45',
'_TZOFFSET_PLUS_05_45'
],
[
'+08:00',
'_TZOFFSET_PLUS_08_00'
],
[
'+09:30',
'_TZOFFSET_PLUS_09_30'
],
[
'+12:00',
'_TZOFFSET_PLUS_12_00'
],
[
'+14:00',
'_TZOFFSET_PLUS_14_00'
]
])('should convert positive offset %s to %s', (offset, expected)=>{
expect(formatUtcOffset(offset)).toEqual(expected);
});
it.each([
[
'-00:00',
'_TZOFFSET_MINUS_00_00'
],
[
'-03:30',
'_TZOFFSET_MINUS_03_30'
],
[
'-05:00',
'_TZOFFSET_MINUS_05_00'
],
[
'-08:00',
'_TZOFFSET_MINUS_08_00'
],
[
'-09:30',
'_TZOFFSET_MINUS_09_30'
],
[
'-12:00',
'_TZOFFSET_MINUS_12_00'
]
])('should convert negative offset %s to %s', (offset, expected)=>{
expect(formatUtcOffset(offset)).toEqual(expected);
});
});
describe('non-offset values', ()=>{
it.each([
'UTC',
'America/New_York',
'Europe/London',
'Asia/Tokyo',
'Pacific/Auckland'
])('should return null for IANA timezone: %s', (timezone)=>{
expect(formatUtcOffset(timezone)).toBeNull();
});
it.each([
'+5',
'-8',
'+05',
'-08',
'+0530',
'-0800',
'05:30',
'0530',
'invalid',
''
])('should return null for non-standard format: %s', (value)=>{
expect(formatUtcOffset(value)).toBeNull();
});
});
describe('uniqueness', ()=>{
it('should produce unique names for positive and negative offsets', ()=>{
const testCases = [
[
'+05:00',
'-05:00'
],
[
'+08:00',
'-08:00'
],
[
'+00:00',
'-00:00'
],
[
'+12:00',
'-12:00'
]
];
for (const [positive, negative] of testCases){
const positiveName = formatUtcOffset(positive);
const negativeName = formatUtcOffset(negative);
expect(positiveName).not.toEqual(negativeName);
}
});
it('should produce unique names for different hour offsets', ()=>{
const offsets = [
'+05:00',
'+06:00',
'+07:00',
'+08:00'
];
const names = offsets.map(formatUtcOffset);
const uniqueNames = new Set(names);
expect(uniqueNames.size).toEqual(offsets.length);
});
it('should produce unique names for different minute offsets', ()=>{
const offsets = [
'+05:00',
'+05:15',
'+05:30',
'+05:45'
];
const names = offsets.map(formatUtcOffset);
const uniqueNames = new Set(names);
expect(uniqueNames.size).toEqual(offsets.length);
});
});
});
//# sourceMappingURL=formatUtcOffset.spec.js.map