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.
66 lines
2.0 KiB
JavaScript
66 lines
2.0 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright (c) 2016, Contributors
|
|
* SPDX-License-Identifier: ISC
|
|
*/
|
|
export function camelCase(str) {
|
|
// Handle the case where an argument is provided as camel case, e.g., fooBar.
|
|
// by ensuring that the string isn't already mixed case:
|
|
const isCamelCase = str !== str.toLowerCase() && str !== str.toUpperCase();
|
|
if (!isCamelCase) {
|
|
str = str.toLowerCase();
|
|
}
|
|
if (str.indexOf('-') === -1 && str.indexOf('_') === -1) {
|
|
return str;
|
|
}
|
|
else {
|
|
let camelcase = '';
|
|
let nextChrUpper = false;
|
|
const leadingHyphens = str.match(/^-+/);
|
|
for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
|
|
let chr = str.charAt(i);
|
|
if (nextChrUpper) {
|
|
nextChrUpper = false;
|
|
chr = chr.toUpperCase();
|
|
}
|
|
if (i !== 0 && (chr === '-' || chr === '_')) {
|
|
nextChrUpper = true;
|
|
}
|
|
else if (chr !== '-' && chr !== '_') {
|
|
camelcase += chr;
|
|
}
|
|
}
|
|
return camelcase;
|
|
}
|
|
}
|
|
export function decamelize(str, joinString) {
|
|
const lowercase = str.toLowerCase();
|
|
joinString = joinString || '-';
|
|
let notCamelcase = '';
|
|
for (let i = 0; i < str.length; i++) {
|
|
const chrLower = lowercase.charAt(i);
|
|
const chrString = str.charAt(i);
|
|
if (chrLower !== chrString && i > 0) {
|
|
notCamelcase += `${joinString}${lowercase.charAt(i)}`;
|
|
}
|
|
else {
|
|
notCamelcase += chrString;
|
|
}
|
|
}
|
|
return notCamelcase;
|
|
}
|
|
export function looksLikeNumber(x) {
|
|
if (x === null || x === undefined)
|
|
return false;
|
|
// if loaded from config, may already be a number.
|
|
if (typeof x === 'number')
|
|
return true;
|
|
// hexadecimal.
|
|
if (/^0x[0-9a-f]+$/i.test(x))
|
|
return true;
|
|
// don't treat 0123 as a number; as it drops the leading '0'.
|
|
if (/^0[^.]/.test(x))
|
|
return false;
|
|
return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
|
}
|