cozy-search
Version:
UI components about search bar and IA assistant
39 lines (37 loc) • 1.64 kB
JavaScript
;
var _helpers = require("./helpers");
describe('sanitizeChatContent', function () {
it('should return empty string for empty content', function () {
expect((0, _helpers.sanitizeChatContent)('')).toBe('');
expect((0, _helpers.sanitizeChatContent)(null)).toBe('');
expect((0, _helpers.sanitizeChatContent)(undefined)).toBe('');
});
it('should return string if no special tags', function () {
var text = 'How you doing, here no ref.';
expect((0, _helpers.sanitizeChatContent)(text)).toBe(text);
});
it('should remove tags REF.../REF', function () {
var text = 'Before REFdoc_1/REF after';
expect((0, _helpers.sanitizeChatContent)(text)).toBe('Before after');
});
it('should remove tags [REF]...[/REF]', function () {
var text = 'Before [REF]doc_1[/REF] after';
expect((0, _helpers.sanitizeChatContent)(text)).toBe('Before after');
});
it('should remove mixed REF tags ', function () {
var text = 'A REF.../REF B [REF]...[/REF] C REF.../REF D';
expect((0, _helpers.sanitizeChatContent)(text)).toBe('A B C D');
});
it('should remove [tags]', function () {
var text = 'Here is a doc [doc_42] and some texte';
expect((0, _helpers.sanitizeChatContent)(text)).toBe('Here is a doc and some texte');
});
it('should not remove simple REF or [REF]', function () {
var text = 'REF not closed [REF]not closed either';
expect((0, _helpers.sanitizeChatContent)(text)).toBe(text);
});
it('should not remove lowercase ref', function () {
var text = 'before refdoc_1/ref after';
expect((0, _helpers.sanitizeChatContent)(text)).toBe(text);
});
});