import React from 'react';
import { markupToReact } from 'translations/markup';
describe('markupToReact', () => {
it('passes plain string as is', () => {
const value = 'string';
const expected = 'string';
expect(markupToReact(value)).toEqual(expected);
});
it('transforms bold syntax', () => {
let value = '**foo**';
let expected = [foo];
expect(markupToReact(value)).toEqual(expected);
value = '**foo** bar';
expected = [foo, ' bar'];
expect(markupToReact(value)).toEqual(expected);
value = 'bar **foo**';
expected = ['bar ', foo];
expect(markupToReact(value)).toEqual(expected);
value = 'bar **foo** baz';
expected = ['bar ', foo, ' baz'];
expect(markupToReact(value)).toEqual(expected);
value = '**foo****bar**';
expected = [foo, bar];
expect(markupToReact(value)).toEqual(expected);
});
it('transforms link syntax', () => {
let value = '[foo](http://google.com)';
let expected = [foo];
expect(markupToReact(value)).toEqual(expected);
value = '[foo](http://google.com) bar';
expected = [foo, ' bar'];
expect(markupToReact(value)).toEqual(expected);
value = 'bar [foo](http://google.com)';
expected = ['bar ', foo];
expect(markupToReact(value)).toEqual(expected);
value = 'bar [foo](http://google.com) baz';
expected = ['bar ', foo, ' baz'];
expect(markupToReact(value)).toEqual(expected);
value = '[foo](http://google.com)[bar](http://google.ca)';
expected = [
foo,
bar
];
expect(markupToReact(value)).toEqual(expected);
});
it('converts mixed syntax', () => {
let value = 'Bold **foo** link [foo](http://google.com) text';
let expected = [
'Bold ',
foo,
' link ',
foo,
' text'
];
expect(markupToReact(value)).toEqual(expected);
});
});