UNPKG

@yoroi/common

Version:

The Common package of Yoroi SDK

56 lines (55 loc) 1.96 kB
"use strict"; var _strings = require("./strings"); describe('asConcatenedString', () => { it('should return undefined for null input', () => { expect((0, _strings.asConcatenedString)(null)).toBeUndefined(); }); it('should return anything else', () => { expect((0, _strings.asConcatenedString)({})).toBeUndefined(); expect((0, _strings.asConcatenedString)(['1', 1])).toBeUndefined(); expect((0, _strings.asConcatenedString)(1)).toBeUndefined(); }); it('should return undefined for undefined input', () => { expect((0, _strings.asConcatenedString)(undefined)).toBeUndefined(); }); it('should return the original string for string input', () => { expect((0, _strings.asConcatenedString)('hello')).toBe('hello'); }); it('should join array of strings into a single string', () => { expect((0, _strings.asConcatenedString)(['h', 'e', 'l', 'l', 'o'])).toBe('hello'); }); }); describe('truncateString', () => { it('should return the original string if its length is less than or equal to maxLength', () => { const value = 'hello'; const maxLength = 10; const result = (0, _strings.truncateString)({ value, maxLength }); expect(result).toBe(value); }); it('should truncate the string and add separator if its length is greater than maxLength', () => { const value = 'This is a long string'; const maxLength = 10; const separator = '-'; const result = (0, _strings.truncateString)({ value, maxLength, separator }); expect(result).toBe('This-ring'); }); it('should truncate the string and add separator at the correct position', () => { const value = 'This is a long string'; const maxLength = 15; const separator = '...'; const result = (0, _strings.truncateString)({ value, maxLength, separator }); expect(result).toBe('This i...string'); }); }); //# sourceMappingURL=strings.test.js.map