UNPKG

e2ed

Version:

E2E testing framework over Playwright

17 lines (16 loc) 731 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getStringTrimmedToMaxLength = void 0; const internal_1 = require("../../constants/internal"); /** * Get string trimmed to max string length in printed value. */ const getStringTrimmedToMaxLength = (text, maxStringLength = internal_1.MAX_STRING_LENGTH_IN_PRINTED_VALUE) => { if (text.length <= maxStringLength) { return text; } const halfOfLength = Math.floor(maxStringLength / 2); const cuttedSymbolsCount = text.length - 2 * halfOfLength; return `${text.slice(0, halfOfLength)}...(${cuttedSymbolsCount} symbols)...${text.slice(-halfOfLength)}`; }; exports.getStringTrimmedToMaxLength = getStringTrimmedToMaxLength;