UNPKG

@tvkitchen/countertop

Version:

The entry point for developers who want to set up a TV Kitchen.

29 lines (25 loc) 1.51 kB
"use strict"; var _kafka = require("../kafka"); describe('kafka #unit', () => { describe('sanitizeTopic', () => { it('Should not change valid topics', () => { expect((0, _kafka.sanitizeTopic)('works')).toBe('works'); expect((0, _kafka.sanitizeTopic)('works.also')).toBe('works.also'); expect((0, _kafka.sanitizeTopic)('works123')).toBe('works123'); }); it('Should replace invalid characters with `-`', () => { expect((0, _kafka.sanitizeTopic)('works!')).toBe('works-'); }); it('Should truncate long strings', () => { const longString = '1234567890123456789012345678901234567890123456789012345678901234567890' // 70 characters + '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' // 90 characters + '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' // 90 characters + '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'; // 90 characters const shortString = '1234567890123456789012345678901234567890123456789012345678901234567890' // 70 characters + '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' // 90 characters + '123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' // 90 characters + '12345'; // 5 characters expect((0, _kafka.sanitizeTopic)(longString)).toBe(shortString); }); }); });