mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-11 11:45:15 +08:00
test(youtube): add tests for start timestamp parsing
This commit is contained in:
parent
6f5a2f2389
commit
1c15e193c1
@ -85,4 +85,53 @@ describe('extension-youtube', () => {
|
|||||||
editor?.destroy()
|
editor?.destroy()
|
||||||
getEditorEl()?.remove()
|
getEditorEl()?.remove()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('start timestamp', () => {
|
||||||
|
const timestamp = 60
|
||||||
|
|
||||||
|
const urls = [
|
||||||
|
{
|
||||||
|
url: `https://www.youtube.com/watch?v=testvideoid&t=${timestamp}s`,
|
||||||
|
expected: `https://www.youtube.com/embed/testvideoid?start=${timestamp}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `https://youtu.be/testvideoid?t=${timestamp}`,
|
||||||
|
expected: `https://www.youtube.com/embed/testvideoid?start=${timestamp}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: `https://www.youtube.com/embed/testvideoid?start=${timestamp}`,
|
||||||
|
expected: `https://www.youtube.com/embed/testvideoid?start=${timestamp}`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
urls.forEach(({ url, expected }) => {
|
||||||
|
it(`parses the start timestamp for url ${url}`, () => {
|
||||||
|
editor = new Editor({
|
||||||
|
element: createEditorEl(),
|
||||||
|
extensions: [
|
||||||
|
Document,
|
||||||
|
Text,
|
||||||
|
Paragraph,
|
||||||
|
Youtube,
|
||||||
|
],
|
||||||
|
content: {
|
||||||
|
type: 'doc',
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: 'youtube',
|
||||||
|
attrs: {
|
||||||
|
src: url,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(editor.getHTML()).to.include(expected)
|
||||||
|
|
||||||
|
editor?.destroy()
|
||||||
|
getEditorEl()?.remove()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user