@playpilot/tpi 5.23.4 → 5.24.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.
@@ -3,11 +3,21 @@ import { describe, expect, it, vi, beforeEach } from 'vitest'
3
3
 
4
4
  import Title from '../../../routes/components/Title.svelte'
5
5
  import { title } from '$lib/fakeData'
6
+ import { fetchParticipantsForTitle } from '$lib/api/participants'
7
+ import { fetchSimilarTitles } from '$lib/api/titles'
6
8
 
7
9
  vi.mock('$lib/tracking', () => ({
8
10
  track: vi.fn(),
9
11
  }))
10
12
 
13
+ vi.mock('$lib/api/participants', () => ({
14
+ fetchParticipantsForTitle: vi.fn(),
15
+ }))
16
+
17
+ vi.mock('$lib/api/titles', () => ({
18
+ fetchSimilarTitles: vi.fn(),
19
+ }))
20
+
11
21
  vi.mock('svelte', async (importActual) => ({
12
22
  ...(await importActual()),
13
23
  getContext: vi.fn(),
@@ -74,4 +84,11 @@ describe('Title.svelte', () => {
74
84
 
75
85
  expect(container.querySelector('.paragraph')).not.toBeTruthy()
76
86
  })
87
+
88
+ it('Should call fetches for participants and similar titles', () => {
89
+ render(Title, { title })
90
+
91
+ expect(fetchParticipantsForTitle).toHaveBeenCalled()
92
+ expect(fetchSimilarTitles).toHaveBeenCalled()
93
+ })
77
94
  })
@@ -15,6 +15,14 @@ vi.mock('$lib/tracking', () => ({
15
15
  track: vi.fn(),
16
16
  }))
17
17
 
18
+ vi.mock('$lib/api/participants', () => ({
19
+ fetchParticipantsForTitle: vi.fn(),
20
+ }))
21
+
22
+ vi.mock('$lib/api/titles', () => ({
23
+ fetchSimilarTitles: vi.fn(),
24
+ }))
25
+
18
26
  describe('TitleModal.svelte', () => {
19
27
  beforeEach(() => {
20
28
  vi.resetAllMocks()
@@ -25,16 +33,14 @@ describe('TitleModal.svelte', () => {
25
33
  vi.useRealTimers()
26
34
  })
27
35
 
28
- const onclose = vi.fn()
29
-
30
36
  it('Should call track function when rendered', () => {
31
- render(TitleModal, { onclose, title })
37
+ render(TitleModal, { title })
32
38
 
33
39
  expect(track).toHaveBeenCalledWith(TrackingEvent.TitleModalView, title)
34
40
  })
35
41
 
36
42
  it('Should call track function when scrolled', async () => {
37
- const { getByRole } = render(TitleModal, { onclose, title })
43
+ const { getByRole } = render(TitleModal, { title })
38
44
 
39
45
  await fireEvent.scroll(getByRole('dialog'))
40
46
 
@@ -44,7 +50,7 @@ describe('TitleModal.svelte', () => {
44
50
  it('Should call track function with time_spent when destroyed', async () => {
45
51
  vi.useFakeTimers()
46
52
 
47
- const { unmount } = render(TitleModal, { onclose, title })
53
+ const { unmount } = render(TitleModal, { title })
48
54
 
49
55
  vi.advanceTimersByTime(200)
50
56
  unmount()
@@ -56,7 +62,7 @@ describe('TitleModal.svelte', () => {
56
62
  // @ts-ignore
57
63
  window.PlayPilotLinkInjections = { ads: [{ campaign_format: 'top_scroll', content: {}, cta: {} }] }
58
64
 
59
- const { container } = render(TitleModal, { onclose, title })
65
+ const { container } = render(TitleModal, { title })
60
66
 
61
67
  expect(container.querySelector('.top-scroll')).toBeTruthy()
62
68
  })
@@ -65,7 +71,7 @@ describe('TitleModal.svelte', () => {
65
71
  // @ts-ignore
66
72
  window.PlayPilotLinkInjections = { ads: null }
67
73
 
68
- const { container } = render(TitleModal, { onclose, title })
74
+ const { container } = render(TitleModal, { title })
69
75
 
70
76
  expect(container.querySelector('.top-scroll')).not.toBeTruthy()
71
77
  })
@@ -74,7 +80,7 @@ describe('TitleModal.svelte', () => {
74
80
  // @ts-ignore
75
81
  window.PlayPilotLinkInjections = { ads: [{ campaign_format: 'card', content: {}, cta: {} }] }
76
82
 
77
- const { container } = render(TitleModal, { onclose, title })
83
+ const { container } = render(TitleModal, { title })
78
84
 
79
85
  expect(container.querySelector('.display')).toBeTruthy()
80
86
  })
@@ -83,7 +89,7 @@ describe('TitleModal.svelte', () => {
83
89
  // @ts-ignore
84
90
  window.PlayPilotLinkInjections = { ads: null }
85
91
 
86
- const { container } = render(TitleModal, { onclose, title })
92
+ const { container } = render(TitleModal, { title })
87
93
 
88
94
  expect(container.querySelector('.display')).not.toBeTruthy()
89
95
  })
@@ -15,6 +15,14 @@ vi.mock('$lib/tracking', () => ({
15
15
  track: vi.fn(),
16
16
  }))
17
17
 
18
+ vi.mock('$lib/api/participants', () => ({
19
+ fetchParticipantsForTitle: vi.fn(),
20
+ }))
21
+
22
+ vi.mock('$lib/api/titles', () => ({
23
+ fetchSimilarTitles: vi.fn(),
24
+ }))
25
+
18
26
  describe('TitlePopover.svelte', () => {
19
27
  beforeEach(() => {
20
28
  vi.resetAllMocks()