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.
98 lines
2.3 KiB
JavaScript
98 lines
2.3 KiB
JavaScript
'use strict'
|
|
const { Minipass } = require('minipass')
|
|
const TYPE = Symbol('type')
|
|
const BUFFER = Symbol('buffer')
|
|
|
|
class Blob {
|
|
constructor (blobParts, options) {
|
|
this[TYPE] = ''
|
|
|
|
const buffers = []
|
|
let size = 0
|
|
|
|
if (blobParts) {
|
|
const a = blobParts
|
|
const length = Number(a.length)
|
|
for (let i = 0; i < length; i++) {
|
|
const element = a[i]
|
|
const buffer = element instanceof Buffer ? element
|
|
: ArrayBuffer.isView(element)
|
|
? Buffer.from(element.buffer, element.byteOffset, element.byteLength)
|
|
: element instanceof ArrayBuffer ? Buffer.from(element)
|
|
: element instanceof Blob ? element[BUFFER]
|
|
: typeof element === 'string' ? Buffer.from(element)
|
|
: Buffer.from(String(element))
|
|
size += buffer.length
|
|
buffers.push(buffer)
|
|
}
|
|
}
|
|
|
|
this[BUFFER] = Buffer.concat(buffers, size)
|
|
|
|
const type = options && options.type !== undefined
|
|
&& String(options.type).toLowerCase()
|
|
if (type && !/[^\u0020-\u007E]/.test(type)) {
|
|
this[TYPE] = type
|
|
}
|
|
}
|
|
|
|
get size () {
|
|
return this[BUFFER].length
|
|
}
|
|
|
|
get type () {
|
|
return this[TYPE]
|
|
}
|
|
|
|
text () {
|
|
return Promise.resolve(this[BUFFER].toString())
|
|
}
|
|
|
|
arrayBuffer () {
|
|
const buf = this[BUFFER]
|
|
const off = buf.byteOffset
|
|
const len = buf.byteLength
|
|
const ab = buf.buffer.slice(off, off + len)
|
|
return Promise.resolve(ab)
|
|
}
|
|
|
|
stream () {
|
|
return new Minipass().end(this[BUFFER])
|
|
}
|
|
|
|
slice (start, end, type) {
|
|
const size = this.size
|
|
const relativeStart = start === undefined ? 0
|
|
: start < 0 ? Math.max(size + start, 0)
|
|
: Math.min(start, size)
|
|
const relativeEnd = end === undefined ? size
|
|
: end < 0 ? Math.max(size + end, 0)
|
|
: Math.min(end, size)
|
|
const span = Math.max(relativeEnd - relativeStart, 0)
|
|
|
|
const buffer = this[BUFFER]
|
|
const slicedBuffer = buffer.slice(
|
|
relativeStart,
|
|
relativeStart + span
|
|
)
|
|
const blob = new Blob([], { type })
|
|
blob[BUFFER] = slicedBuffer
|
|
return blob
|
|
}
|
|
|
|
get [Symbol.toStringTag] () {
|
|
return 'Blob'
|
|
}
|
|
|
|
static get BUFFER () {
|
|
return BUFFER
|
|
}
|
|
}
|
|
|
|
Object.defineProperties(Blob.prototype, {
|
|
size: { enumerable: true },
|
|
type: { enumerable: true },
|
|
})
|
|
|
|
module.exports = Blob
|