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.
cli-truncate
Truncate a string to a specific width in the terminal
Gracefully handles ANSI escapes. Like a string styled with chalk. It also supports Unicode surrogate pairs and fullwidth characters.
Install
npm install cli-truncate
Usage
import cliTruncate from 'cli-truncate';
cliTruncate('unicorn', 4);
//=> 'uni…'
// Truncate at different positions
cliTruncate('unicorn', 4, {position: 'start'});
//=> '…orn'
cliTruncate('unicorn', 4, {position: 'middle'});
//=> 'un…n'
cliTruncate('unicorns rainbow dragons', 6, {position: 'end'});
//=> 'unico…'
cliTruncate('\u001B[31municorn\u001B[39m', 4);
//=> '\u001B[31muni…\u001B[39m'
> [!NOTE]
> When truncating styled text (ANSI escapes), the truncation character inherits the style at the breaking point for `position: 'start'` and `position: 'end'`. This does not apply to `position: 'middle'`.
// Truncate Unicode surrogate pairs
cliTruncate('uni\uD83C\uDE00corn', 5);
//=> 'uni\uD83C\uDE00…'
// Truncate fullwidth characters
cliTruncate('안녕하세요', 3);
//=> '안…'
// Truncate the paragraph to the terminal width
const paragraph = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.';
cliTruncate(paragraph, process.stdout.columns);
//=> 'Lorem ipsum dolor sit amet, consectetuer adipiscing…'
API
cliTruncate(text, columns, options?)
text
Type: string
The text to truncate.
columns
Type: number
The number of columns to occupy in the terminal.
options
Type: object
position
Type: string
Default: 'end'
Values: 'start' | 'middle' | 'end'
The position to truncate the string.
space
Type: boolean
Default: false
Add a space between the text and the ellipsis.
import cliTruncate from 'cli-truncate';
cliTruncate('unicorns', 5, {space: false});
//=> 'unic…'
cliTruncate('unicorns', 5, {space: true});
//=> 'uni …'
cliTruncate('unicorns', 6, {position: 'start', space: true});
//=> '… orns'
cliTruncate('unicorns', 7, {position: 'middle', space: true});
//=> 'uni … s'
preferTruncationOnSpace
Type: boolean
Default: false
Truncate the string from a whitespace if it is within 3 characters from the actual breaking point.
import cliTruncate from 'cli-truncate';
cliTruncate('unicorns rainbow dragons', 20, {position: 'start', preferTruncationOnSpace: true});
//=> '…rainbow dragons'
// Without preferTruncationOnSpace
cliTruncate('unicorns rainbow dragons', 20, {position: 'start'});
//=> '…rns rainbow dragons'
cliTruncate('unicorns rainbow dragons', 20, {position: 'middle', preferTruncationOnSpace: true});
//=> 'unicorns…dragons'
cliTruncate('unicorns rainbow dragons', 6, {position: 'end', preferTruncationOnSpace: true});
//=> 'unico…'
// preferTruncationOnSpace has no effect if space isn't found within 3 characters
cliTruncate('unicorns rainbow dragons', 6, {position: 'middle', preferTruncationOnSpace: true});
//=> 'uni…ns'
truncationCharacter
Type: string
Default: …
The character to use at the breaking point.
import cliTruncate from 'cli-truncate';
cliTruncate('unicorns', 5, {position: 'end'});
//=> 'unic…'
cliTruncate('unicorns', 5, {position: 'end', truncationCharacter: '.'});
//=> 'unic.'
cliTruncate('unicorns', 5, {position: 'end', truncationCharacter: ''});
//=> 'unico'
Related
- wrap-ansi - Wordwrap a string with ANSI escape codes
- slice-ansi - Slice a string with ANSI escape codes