import { linkAnchor } from '../anchor'; const url = 'https://shop.test/kettles/'; describe('linkAnchor', () => { it('wraps the first plain-text occurrence', () => { expect( linkAnchor( '
A cast iron kettle keeps tea warm.
', 'cast iron kettle', url ) ).toBe(`A cast iron kettle keeps tea warm.
`); }); it('keeps the text as it was written', () => { expect( linkAnchor( 'The Cast Iron Kettle is heavy.
', 'cast iron kettle', url ) ).toBe(`The Cast Iron Kettle is heavy.
`); }); it('ignores accents on either side', () => { expect( linkAnchor( 'Un ceainic din fontă e greu.
', 'ceainic din fonta', url ) ).toBe(`Un ceainic din fontă e greu.
`); }); it('never links inside a link or a heading', () => { expect( linkAnchor( 'An cast iron kettle and a cast iron kettle.
', 'cast iron kettle', url ) ).toBe( `An cast iron kettle and a cast iron kettle.
` ); }); it('does not match inside a tag or a block comment', () => { expect( linkAnchor( 'Teapots only.
', 'cast iron kettle', url) ).toBeNull(); expect(linkAnchor('Anything.
', ' ', url)).toBeNull(); }); });