UNPKG

@apite/magento2-utility

Version:

Shopgate WebCheckout utility for Magento 2 extensions

42 lines (30 loc) 1.28 kB
const { formatRoute } = require('../../src/services/urlManager') test('formatRoute should handle strings with special characters and slashes', () => { const input = '/special/char@123/with/slashes///' const expectedOutput = 'special/char@123/with/slashes' expect(formatRoute(input)).toBe(expectedOutput) }) test('Should return the same string when the input does not contain leading or trailing slashes', () => { const input = 'testRoute' const expectedOutput = 'testRoute' const result = formatRoute(input) expect(result).toBe(expectedOutput) }) test('formatRoute should handle strings with mixed leading and trailing slashes', () => { const input = '///foo/bar///' const expectedOutput = 'foo/bar' expect(formatRoute(input)).toBe(expectedOutput) }) test('formatRoute removes leading and trailing forward slashes from a string with multiple slashes', () => { const input = '///example///' const expectedOutput = 'example' const result = formatRoute(input) expect(result).toBe(expectedOutput) }) test('formatRoute should return null when the input is not a string', () => { const input = 123 const expectedOutput = null // noinspection JSCheckFunctionSignatures const result = formatRoute(input) expect(result).toBe(expectedOutput) })