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.
89 lines
2.7 KiB
JavaScript
89 lines
2.7 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = timeout;
|
|
|
|
var _initialParams = require('./internal/initialParams.js');
|
|
|
|
var _initialParams2 = _interopRequireDefault(_initialParams);
|
|
|
|
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
|
|
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Sets a time limit on an asynchronous function. If the function does not call
|
|
* its callback within the specified milliseconds, it will be called with a
|
|
* timeout error. The code property for the error object will be `'ETIMEDOUT'`.
|
|
*
|
|
* @name timeout
|
|
* @static
|
|
* @memberOf module:Utils
|
|
* @method
|
|
* @category Util
|
|
* @param {AsyncFunction} asyncFn - The async function to limit in time.
|
|
* @param {number} milliseconds - The specified time limit.
|
|
* @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
|
|
* to timeout Error for more information..
|
|
* @returns {AsyncFunction} Returns a wrapped function that can be used with any
|
|
* of the control flow functions.
|
|
* Invoke this function with the same parameters as you would `asyncFunc`.
|
|
* @example
|
|
*
|
|
* function myFunction(foo, callback) {
|
|
* doAsyncTask(foo, function(err, data) {
|
|
* // handle errors
|
|
* if (err) return callback(err);
|
|
*
|
|
* // do some stuff ...
|
|
*
|
|
* // return processed data
|
|
* return callback(null, data);
|
|
* });
|
|
* }
|
|
*
|
|
* var wrapped = async.timeout(myFunction, 1000);
|
|
*
|
|
* // call `wrapped` as you would `myFunction`
|
|
* wrapped({ bar: 'bar' }, function(err, data) {
|
|
* // if `myFunction` takes < 1000 ms to execute, `err`
|
|
* // and `data` will have their expected values
|
|
*
|
|
* // else `err` will be an Error with the code 'ETIMEDOUT'
|
|
* });
|
|
*/
|
|
function timeout(asyncFn, milliseconds, info) {
|
|
var fn = (0, _wrapAsync2.default)(asyncFn);
|
|
|
|
return (0, _initialParams2.default)((args, callback) => {
|
|
var timedOut = false;
|
|
var timer;
|
|
|
|
function timeoutCallback() {
|
|
var name = asyncFn.name || 'anonymous';
|
|
var error = new Error('Callback function "' + name + '" timed out.');
|
|
error.code = 'ETIMEDOUT';
|
|
if (info) {
|
|
error.info = info;
|
|
}
|
|
timedOut = true;
|
|
callback(error);
|
|
}
|
|
|
|
args.push((...cbArgs) => {
|
|
if (!timedOut) {
|
|
callback(...cbArgs);
|
|
clearTimeout(timer);
|
|
}
|
|
});
|
|
|
|
// setup timer and call original function
|
|
timer = setTimeout(timeoutCallback, milliseconds);
|
|
fn(...args);
|
|
});
|
|
}
|
|
module.exports = exports.default; |