@playpilot/tpi 5.34.2 → 5.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ import { fireEvent, render } from '@testing-library/svelte'
2
+ import { describe, expect, it, vi } from 'vitest'
3
+
4
+ import YouTubeEmbedOverlay from '../../../routes/components/YouTubeEmbedOverlay.svelte'
5
+
6
+ describe('YouTubeEmbedOverlay.svelte', () => {
7
+ it('Should render embed iframe with given video url', () => {
8
+ const { container } = render(YouTubeEmbedOverlay, { embeddable_url: 'youtube.com/watch?v=abc', onclose: () => null })
9
+
10
+ // @ts-ignore
11
+ expect(container.querySelector('iframe').src).toBe('https://www.youtube.com/embed/abc?autoplay=true')
12
+ })
13
+
14
+ it('Should render error message if embeddable_url is invalid', () => {
15
+ const { container, getByText } = render(YouTubeEmbedOverlay, { embeddable_url: '-', onclose: () => null })
16
+
17
+ expect(container.querySelector('iframe')).not.toBeTruthy()
18
+ expect(getByText('Something went wrong')).toBeTruthy()
19
+ })
20
+
21
+ it('Should fire given onclose function on click of close button and backdrop', async () => {
22
+ const onclose = vi.fn()
23
+ const { getByLabelText, getByTestId } = render(YouTubeEmbedOverlay, { embeddable_url: '-', onclose })
24
+
25
+ await fireEvent.click(getByLabelText('Close'))
26
+ expect(onclose).toHaveBeenCalledTimes(1)
27
+
28
+ await fireEvent.click(getByTestId('backdrop'))
29
+ expect(onclose).toHaveBeenCalledTimes(2)
30
+ })
31
+ })