<commit_before>import markdown from '../../src/.utils/react/markdown'

describe('markdown.js', () => {
    it('should return whole string', () => {
        const sentence = 'press "Delete"'
        const failed = [{
            mark: null,
            prop: null,
            text: sentence
        }]
        expect(markdown('', ['*'])[0].text).toBe('')
        expect(markdown(sentence)).toEqual(failed)
        expect(markdown(sentence, null)).toEqual(failed)
        expect(markdown(sentence, [])).toEqual(failed)
    })

    it('string starts with no mark', () => {
        let result = markdown('not *asterisk*', ['*'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '*', prop: null, text: 'asterisk' }
        ])
    })

    it('string starts with mark', () => {
        let result = markdown('*asterisk* to end', ['*'])
        expect(result).toEqual([
            { mark: '*', prop: null, text: 'asterisk' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('string with multiple marks', () => {
        let result = markdown('not "quote" and "again" to end', ['"'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '"', prop: null, text: 'quote' },
            { mark: null, prop: null, text: ' and ' },
            { mark: '"', prop: null, text: 'again' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('string with multiple different marks', () => {
        let result = markdown('not *asterisk* "quote" to end', ['*', '"'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '*', prop: null, text: 'asterisk' },
            { mark: null, prop: null, text: ' ' },
            { mark: '"', prop: null, text: 'quote' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('string with multiple marks next to each other', () => {
        let result = markdown('not *asterisk*"quote" to end', ['*', '"'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '*', prop: null, text: 'asterisk' },
            { mark: '"', prop: null, text: 'quote' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('marks with different open and close tag', () => {
        let result = markdown('not (parentheses) to end', ['()'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '()', prop: null, text: 'parentheses' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })
<commit_msg>add more tests<commit_after>import markdown from '../../src/.utils/react/markdown'

describe('markdown.js', () => {
    it('should return whole string', () => {
        const sentence = 'press "Delete"'
        const failed = [{
            mark: null,
            prop: null,
            text: sentence
        }]
        expect(markdown('', ['*'])[0].text).toBe('')
        expect(markdown(sentence)).toEqual(failed)
        expect(markdown(sentence, null)).toEqual(failed)
        expect(markdown(sentence, [])).toEqual(failed)
    })

    it('throws on opening tag without closing', () => {
        expect(() => {
            markdown('not *asterisk "quote" end', ['*', '"'])
        }).toThrow()
    })

    it('string starts with no mark', () => {
        let result = markdown('not *asterisk*', ['*'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '*', prop: null, text: 'asterisk' }
        ])
    })

    it('string starts with mark', () => {
        let result = markdown('*asterisk* to end', ['*'])
        expect(result).toEqual([
            { mark: '*', prop: null, text: 'asterisk' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('string with multiple marks', () => {
        let result = markdown('not "quote" and "again" to end', ['"'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '"', prop: null, text: 'quote' },
            { mark: null, prop: null, text: ' and ' },
            { mark: '"', prop: null, text: 'again' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('string with multiple different marks', () => {
        let result = markdown('not *asterisk* "quote" to end', ['*', '"'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '*', prop: null, text: 'asterisk' },
            { mark: null, prop: null, text: ' ' },
            { mark: '"', prop: null, text: 'quote' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('string with multiple marks next to each other', () => {
        let result = markdown('not *asterisk*"quote" to end', ['*', '"'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '*', prop: null, text: 'asterisk' },
            { mark: '"', prop: null, text: 'quote' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('marks with different opening and closing tag', () => {
        let result = markdown('not (parentheses) to end', ['()'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '()', prop: null, text: 'parentheses' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('mark with double opening tag', () => {
        let result = markdown('not ((parentheses) to end', ['()'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '()', prop: null, text: '(parentheses' },
            { mark: null, prop: null, text: ' to end' }
        ])
    })

    it('mark with double closing tag', () => {
        let result = markdown('not (parentheses)) to end', ['()'])
        expect(result).toEqual([
            { mark: null, prop: null, text: 'not ' },
            { mark: '()', prop: null, text: 'parentheses' },
            { mark: null, prop: null, text: ') to end' }
        ])
    })

{'fraction_non_alphanumeric': 0.19583200763601655, 'fraction_numerical': 0.0003181673560292714, 'mean_word_length': 1.9558062999529855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2105716', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1866, 'n_words': 522}