test(youtube): add tests for Live, Shorts URLs

This commit is contained in:
Phillmont Muktar 2025-05-29 14:29:43 +08:00
parent 1c15e193c1
commit 0749b9cac2

View File

@ -134,4 +134,60 @@ describe('extension-youtube', () => {
}) })
}) })
}) })
it('parses live url', () => {
editor = new Editor({
element: createEditorEl(),
extensions: [
Document,
Text,
Paragraph,
Youtube,
],
content: {
type: 'doc',
content: [
{
type: 'youtube',
attrs: {
src: 'https://www.youtube.com/live/testvideoid',
},
},
],
},
})
expect(editor.getHTML()).to.include('https://www.youtube.com/embed/testvideoid')
editor?.destroy()
getEditorEl()?.remove()
})
it('parses shorts url', () => {
editor = new Editor({
element: createEditorEl(),
extensions: [
Document,
Text,
Paragraph,
Youtube,
],
content: {
type: 'doc',
content: [
{
type: 'youtube',
attrs: {
src: 'https://www.youtube.com/shorts/testvideoid',
},
},
],
},
})
expect(editor.getHTML()).to.include('https://www.youtube.com/embed/testvideoid')
editor?.destroy()
getEditorEl()?.remove()
})
}) })