60e2149072
Tasks 16-20: Online Board Tests (Search/Filter, Tabs, Flight List, Details Modal, Time/Date) - Task 16: Search & Filter tests (37 tests) - departure/arrival cities, passenger count, cabin class - Task 17: Arrival/Departure Tabs tests (45 tests) - tab switching, flight display, sorting - Task 18: Flight List View tests (50 tests) - display, sorting, filtering, pagination, loading states - Task 19: Flight Details Modal tests (40 tests) - opening/closing, content display, actions - Task 20: Time & Date Filter tests (43 tests) - date selection, time ranges, calendar navigation Tasks 21-25: Flight Details Tests (Flight Info, Passengers, Seats, Services, Fares) - Task 21: Flight Info Display tests (40 tests) - basic info, airports, route visualization, timeline - Task 22: Passenger Info tests (50 tests) - passenger list, details, services, special requirements - Task 23: Seat Selection tests (50 tests) - seat map, selection, categories, recommendations - Task 24: Service Selection tests (25 tests) - baggage, meals, seats, summary - Task 25: Fare Display tests (55 tests) - fare breakdown, comparisons, discounts, refunds All tests follow AAA pattern and use data-testid selectors matching Angular version. Total: 245 tests across 10 feature suites.
136 lines
2.8 KiB
JavaScript
136 lines
2.8 KiB
JavaScript
import {
|
|
ambiguousRanges,
|
|
fullwidthRanges,
|
|
halfwidthRanges,
|
|
narrowRanges,
|
|
wideRanges,
|
|
} from './lookup-data.js';
|
|
import {isInRange} from './utilities.js';
|
|
|
|
const minimumAmbiguousCodePoint = ambiguousRanges[0];
|
|
const maximumAmbiguousCodePoint = ambiguousRanges.at(-1);
|
|
const minimumFullWidthCodePoint = fullwidthRanges[0];
|
|
const maximumFullWidthCodePoint = fullwidthRanges.at(-1);
|
|
const minimumHalfWidthCodePoint = halfwidthRanges[0];
|
|
const maximumHalfWidthCodePoint = halfwidthRanges.at(-1);
|
|
const minimumNarrowCodePoint = narrowRanges[0];
|
|
const maximumNarrowCodePoint = narrowRanges.at(-1);
|
|
const minimumWideCodePoint = wideRanges[0];
|
|
const maximumWideCodePoint = wideRanges.at(-1);
|
|
|
|
const commonCjkCodePoint = 0x4E_00;
|
|
const [wideFastPathStart, wideFastPathEnd] = findWideFastPathRange(wideRanges);
|
|
|
|
// Use a hot-path range so common `isWide` calls can skip binary search.
|
|
// The range containing U+4E00 covers common CJK ideographs;
|
|
// fallback to the largest range for resilience to Unicode table changes.
|
|
function findWideFastPathRange(ranges) {
|
|
let fastPathStart = ranges[0];
|
|
let fastPathEnd = ranges[1];
|
|
|
|
for (let index = 0; index < ranges.length; index += 2) {
|
|
const start = ranges[index];
|
|
const end = ranges[index + 1];
|
|
|
|
if (
|
|
commonCjkCodePoint >= start
|
|
&& commonCjkCodePoint <= end
|
|
) {
|
|
return [start, end];
|
|
}
|
|
|
|
if ((end - start) > (fastPathEnd - fastPathStart)) {
|
|
fastPathStart = start;
|
|
fastPathEnd = end;
|
|
}
|
|
}
|
|
|
|
return [fastPathStart, fastPathEnd];
|
|
}
|
|
|
|
export const isAmbiguous = codePoint => {
|
|
if (
|
|
codePoint < minimumAmbiguousCodePoint
|
|
|| codePoint > maximumAmbiguousCodePoint
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return isInRange(ambiguousRanges, codePoint);
|
|
};
|
|
|
|
export const isFullWidth = codePoint => {
|
|
if (
|
|
codePoint < minimumFullWidthCodePoint
|
|
|| codePoint > maximumFullWidthCodePoint
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return isInRange(fullwidthRanges, codePoint);
|
|
};
|
|
|
|
const isHalfWidth = codePoint => {
|
|
if (
|
|
codePoint < minimumHalfWidthCodePoint
|
|
|| codePoint > maximumHalfWidthCodePoint
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return isInRange(halfwidthRanges, codePoint);
|
|
};
|
|
|
|
const isNarrow = codePoint => {
|
|
if (
|
|
codePoint < minimumNarrowCodePoint
|
|
|| codePoint > maximumNarrowCodePoint
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return isInRange(narrowRanges, codePoint);
|
|
};
|
|
|
|
export const isWide = codePoint => {
|
|
if (
|
|
codePoint >= wideFastPathStart
|
|
&& codePoint <= wideFastPathEnd
|
|
) {
|
|
return true;
|
|
}
|
|
|
|
if (
|
|
codePoint < minimumWideCodePoint
|
|
|| codePoint > maximumWideCodePoint
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return isInRange(wideRanges, codePoint);
|
|
};
|
|
|
|
export function getCategory(codePoint) {
|
|
if (isAmbiguous(codePoint)) {
|
|
return 'ambiguous';
|
|
}
|
|
|
|
if (isFullWidth(codePoint)) {
|
|
return 'fullwidth';
|
|
}
|
|
|
|
if (isHalfWidth(codePoint)) {
|
|
return 'halfwidth';
|
|
}
|
|
|
|
if (isNarrow(codePoint)) {
|
|
return 'narrow';
|
|
}
|
|
|
|
if (isWide(codePoint)) {
|
|
return 'wide';
|
|
}
|
|
|
|
return 'neutral';
|
|
}
|