import defaultExtensions from './defaultExtensions.js' import { Editor } from 'tiptap' let content let createEditor describe('defaultExtensions', () => { describe('editor', () => { createEditor = () => { const componentStub = { placeholder: 'placeholder', $t: jest.fn(), $apollo: { mutate: jest.fn(), }, } return new Editor({ content, extensions: [...defaultExtensions(componentStub)], }) } }) it('renders', () => { content = '' expect(createEditor().getHTML()).toEqual('

') }) describe('`content` contains a mentioning', () => { beforeEach(() => { content = '

This is a post content mentioning @alicia-luettgen.

' }) it('renders mentioning as link', () => { const editor = createEditor() const expected = '

This is a post content mentioning @alicia-luettgen.

' expect(editor.getHTML()).toEqual(expected) }) }) describe('`content` contains a hashtag', () => { beforeEach(() => { content = '

This is a post content with a hashtag #metoo.

' }) it('renders hashtag as link', () => { const editor = createEditor() const expected = '

This is a post content with a hashtag #metoo.

' expect(editor.getHTML()).toEqual(expected) }) }) describe('`content` contains embed code', () => { beforeEach(() => { content = '

Baby loves cat:

' }) it('recognizes embed code', () => { const editor = createEditor() const expected = { type: 'doc', content: [ { content: [ { text: 'Baby loves cat:', type: 'text', }, ], type: 'paragraph', }, { content: [ { attrs: { dataEmbedUrl: 'https://www.youtube.com/watch?v=qkdXAtO40Fo', }, type: 'embed', }, ], type: 'paragraph', }, ], } expect(editor.getJSON()).toEqual(expected) }) }) })