import { createCommentUri, createEditedCommentUri, createEditedReplyUri, createNewCommentUri, createNewReplyUri, processMentions, transformPlainTextValueToValueWithMentions } from './helpers';
describe('utils tests', function () {
    describe('processMentions behaviour', function () {
        it('should work correctly if mentions does not exist', function () {
            var processor = jest.fn(function (value) { return "(((".concat(value, ")))"); });
            var string1 = 'Hello world!';
            expect(processMentions(string1, [], processor)).toEqual([string1]);
            expect(processMentions(string1, [], processor).join('')).toBe(string1);
            var string2 = '';
            expect(processMentions(string2, [], processor)).toEqual([]);
            expect(processMentions(string2, [], processor).join('')).toBe(string2);
            var string3 = 'Hello + world!';
            expect(processMentions(string3, [], processor)).toEqual(['Hello ', '+ world!']);
            expect(processMentions(string3, [], processor).join('')).toBe(string3);
            var string4 = '+username + and + +username2';
            expect(processMentions(string4, [], processor)).toEqual(['+username ', '+ and ', '+ ', '+username2']);
            expect(processMentions(string4, [], processor).join('')).toBe(string4);
            expect(processor).not.toHaveBeenCalled();
        });
        it('should work correctly if mentions exists', function () {
            var processor = jest.fn(function (value) { return "(((".concat(value, ")))"); });
            expect(processMentions('+username Hello!', ['username'], processor)).toEqual([
                '(((+username)))',
                ' Hello!'
            ]);
            expect(processMentions('Hello +username!', ['username'], processor)).toEqual([
                'Hello ',
                '(((+username)))',
                '!'
            ]);
            expect(processMentions('Hello +username and username2', ['username'], processor)).toEqual([
                'Hello ',
                '(((+username)))',
                ' and username2'
            ]);
            expect(processMentions('Hello + username +', ['username'], processor)).toEqual([
                'Hello ',
                '+ username ',
                '+'
            ]);
            expect(processMentions('Hello username and username2', ['username', 'username2'], processor)).toEqual([
                'Hello username and username2'
            ]);
            expect(processMentions('Hello ++username', ['username'], processor)).toEqual([
                'Hello ',
                '+',
                '(((+username)))',
                ''
            ]);
        });
    });
    describe('createNewCommentUri behaviour', function () {
        it('should return correct uri', function () {
            expect(createNewCommentUri()).toBe('comment/new');
        });
    });
    describe('createNewReplyUri behaviour', function () {
        it('should return correct uri', function () {
            expect(createNewReplyUri({ commentId: '1' })).toBe('comment/1/reply/new');
            expect(createNewReplyUri({ commentId: '2' })).toBe('comment/2/reply/new');
        });
    });
    describe('createEditedCommentUri behaviour', function () {
        it('should return correct uri', function () {
            expect(createEditedCommentUri({ commentId: '1' })).toBe('comment/1');
            expect(createEditedCommentUri({ commentId: '2' })).toBe('comment/2');
        });
    });
    describe('createEditedReplyUri behaviour', function () {
        it('should return correct uri', function () {
            expect(createEditedReplyUri({ commentId: '1' }, { replyId: '1' })).toBe('comment/1/reply/1');
            expect(createEditedReplyUri({ commentId: '1' }, { replyId: '2' })).toBe('comment/1/reply/2');
            expect(createEditedReplyUri({ commentId: '2' }, { replyId: '3' })).toBe('comment/2/reply/3');
        });
    });
    describe('createCommentUri behaviour', function () {
        it('should return correct uri', function () {
            expect(createCommentUri({ comment: null, reply: null, isEditingComment: true, isEditingReply: true })).toBe('comment/new');
            expect(createCommentUri({
                comment: { commentId: '1' },
                reply: null,
                isEditingComment: true,
                isEditingReply: false
            })).toBe('comment/1');
            expect(createCommentUri({
                comment: { commentId: '1' },
                reply: { replyId: '1' },
                isEditingComment: false,
                isEditingReply: true
            })).toBe('comment/1/reply/1');
            expect(createCommentUri({
                comment: { commentId: '1' },
                reply: null,
                isEditingComment: false,
                isEditingReply: false
            })).toBe('comment/1/reply/new');
        });
    });
    describe('transformPlainTextValueToValueWithMentions behaviour', function () {
        it('should work correctly without mentions', function () {
            expect(transformPlainTextValueToValueWithMentions('hello world', [])).toBe('hello world');
        });
        it('should work correctly with mentions', function () {
            expect(transformPlainTextValueToValueWithMentions('hello +_dapie and +ainsteisha', ['_dapie', 'ainsteisha'])).toBe('hello @[_dapie](_dapie) and @[ainsteisha](ainsteisha)');
            expect(transformPlainTextValueToValueWithMentions('hello +_dapie and +ainsteisha, +_dapie can you approve me please', ['_dapie', 'ainsteisha'])).toBe('hello @[_dapie](_dapie) and @[ainsteisha](ainsteisha), @[_dapie](_dapie) can you approve me please');
            expect(transformPlainTextValueToValueWithMentions('hello +_dapie and +ainsteisha', ['ainsteisha'])).toBe('hello +_dapie and @[ainsteisha](ainsteisha)');
            expect(transformPlainTextValueToValueWithMentions('hello +++++ainsteisha', ['ainsteisha'])).toBe('hello ++++@[ainsteisha](ainsteisha)');
        });
    });
});
