@playpilot/tpi 8.40.1 → 8.41.0-beta.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "8.40.1",
3
+ "version": "8.41.0-beta.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -4,4 +4,9 @@ export const SplitTest = {
4
4
  numberOfVariants: 2,
5
5
  variantNames: ['Separated', 'Inline'] as string[],
6
6
  },
7
+ DisplayAdFormat: {
8
+ key: 'display_ad_format',
9
+ numberOfVariants: 3,
10
+ variantNames: ['Default', 'Tall', 'Inline'] as string[],
11
+ },
7
12
  } as const
@@ -172,10 +172,10 @@ export const campaign: Campaign = {
172
172
  campaign_region: 'nl',
173
173
  content: {
174
174
  header: 'Content header',
175
- header_logo: null,
175
+ header_logo: 'https://placehold.co/50?text=content.header_logo',
176
176
  header_logo_uuid: null,
177
177
  subheader: 'Content subheader',
178
- image: null,
178
+ image: 'https://placehold.co/320x180/333/666?text=content.image',
179
179
  image_uuid: null,
180
180
  video: null,
181
181
  format: null,
@@ -6,18 +6,23 @@
6
6
  import { onDestroy } from 'svelte'
7
7
  import Tooltip from '../Tooltip.svelte'
8
8
  import Disclaimer from './Disclaimer.svelte'
9
+ import { getSplitTestVariantName } from '$lib/splitTest'
10
+ import { SplitTest } from '$lib/enums/SplitTest'
9
11
 
10
12
  interface Props {
11
13
  campaign: Campaign
12
14
  compact?: boolean
15
+ slim?: boolean
13
16
  }
14
17
 
15
- const { campaign, compact = false }: Props = $props()
18
+ const { campaign, compact = false, slim = false }: Props = $props()
16
19
 
17
20
  const { disclaimer, content, cta, campaign_type } = $derived(campaign)
18
21
  const { header, subheader, header_logo: logo, image, video } = $derived(content)
19
22
  const { header: buttonLabel, url: href, subheader: info } = $derived(cta)
20
23
 
24
+ const tall = slim && getSplitTestVariantName(SplitTest.DisplayAdFormat) === 'Tall'
25
+
21
26
  let contentHeight = $state(0)
22
27
  let videoElement: HTMLVideoElement | null = $state(null)
23
28
 
@@ -34,8 +39,8 @@
34
39
  })
35
40
  </script>
36
41
 
37
- <a {href} target="_blank" class="display" class:compact rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
38
- {#if info}
42
+ <a {href} target="_blank" class="display" class:compact class:slim class:tall rel="sponsored" {onclick} use:middlemouse={{ onclick }}>
43
+ {#if info && !slim}
39
44
  <div class="info">
40
45
  {#if compact}
41
46
  <Tooltip>
@@ -62,7 +67,7 @@
62
67
  <span class="name">{header}</span>
63
68
  {/if}
64
69
 
65
- {#if subheader}
70
+ {#if subheader && !slim}
66
71
  <div class="subheader">{subheader}</div>
67
72
  {/if}
68
73
  </div>
@@ -90,6 +95,8 @@
90
95
  </a>
91
96
 
92
97
  <style lang="scss">
98
+ $background-color: rgb(110, 110, 110);
99
+
93
100
  .display {
94
101
  display: block;
95
102
  position: relative;
@@ -102,6 +109,16 @@
102
109
  font-family: theme(detail-font-family, font-family);
103
110
  line-height: 1.2;
104
111
  font-style: normal !important;
112
+
113
+ &.slim {
114
+ aspect-ratio: unset;
115
+ height: margin(5.5);
116
+ background: $background-color;
117
+
118
+ &.tall {
119
+ height: margin(8);
120
+ }
121
+ }
105
122
  }
106
123
 
107
124
  .info {
@@ -131,7 +148,7 @@
131
148
  bottom: 0;
132
149
  left: 0;
133
150
  padding: margin(0.5);
134
- background: linear-gradient(to right, rgba(110, 110, 110, 1), rgba(85, 85, 85, 0.3));
151
+ background: linear-gradient(to right, $background-color, rgba(85, 85, 85, 0.3));
135
152
  font-size: margin(0.875);
136
153
  text-decoration: none;
137
154
 
@@ -142,10 +159,25 @@
142
159
  padding: margin(0.75);
143
160
  }
144
161
  }
162
+
163
+ .slim & {
164
+ background: transparent;
165
+ padding-left: margin(10.5);
166
+ height: 100%;
167
+ font-size: theme(font-size-small);
168
+ }
145
169
  }
146
170
 
147
171
  .logo {
148
172
  border-radius: theme(display-ad-border-radius, border-radius);
173
+
174
+ .slim & {
175
+ position: absolute;
176
+ width: margin(1.5);
177
+ height: margin(1.5);
178
+ bottom: margin(0.5);
179
+ left: margin(0.5);
180
+ }
149
181
  }
150
182
 
151
183
  .name {
@@ -176,11 +208,26 @@
176
208
  display: block;
177
209
  width: 100%;
178
210
  height: auto;
211
+
212
+ .slim & {
213
+ width: auto;
214
+ height: 100%;
215
+ aspect-ratio: 16 / 9;
216
+ background: black;
217
+ }
218
+
219
+ .tall & {
220
+ mask-image: linear-gradient(to right, white 50%, transparent);
221
+ }
179
222
  }
180
223
 
181
224
  .disclaimer {
182
225
  position: absolute;
183
226
  bottom: calc(var(--offset) + margin(0.25));
184
227
  right: margin(0.25);
228
+
229
+ .slim & {
230
+ bottom: margin(0.25);
231
+ }
185
232
  }
186
233
  </style>
@@ -76,6 +76,8 @@
76
76
  campaign_name: 'some_campaign',
77
77
  // @ts-ignore
78
78
  content: {
79
+ header_logo: 'https://placehold.co/50?text=content.header_logo',
80
+ image: 'https://placehold.co/320x180/333/666?text=content.image',
79
81
  header: 'Content header',
80
82
  subheader: 'Content subheader',
81
83
  },
@@ -153,14 +153,6 @@
153
153
  }
154
154
  }
155
155
 
156
- .description {
157
- max-width: theme(explore-header-max-width, 600px);
158
- margin: 0;
159
- color: theme(text-color-alt);
160
- font-size: theme(font-size-base);
161
- line-height: 1.35;
162
- }
163
-
164
156
  .filter {
165
157
  display: flex;
166
158
  flex-direction: column;
@@ -9,6 +9,8 @@
9
9
  import IconArrow from '../Icons/IconArrow.svelte'
10
10
  import ModalCloseOverlay from './ModalCloseOverlay.svelte'
11
11
  import Display from '../Ads/Display.svelte'
12
+ import { SplitTest } from '$lib/enums/SplitTest'
13
+ import { getSplitTestVariantName, trackSplitTestView } from '$lib/splitTest'
12
14
 
13
15
  interface Props {
14
16
  items: Record<string, any>[]
@@ -27,6 +29,8 @@
27
29
  let element: HTMLElement | null = $state(null)
28
30
  let displayAd = $state(getFirstAdOfType('card'))
29
31
 
32
+ if (!!displayAd) trackSplitTestView(SplitTest.DisplayAdFormat)
33
+
30
34
  onMount(() => {
31
35
  setAvailableHeight()
32
36
 
@@ -60,9 +64,9 @@
60
64
  <svelte:window onresize={setAvailableHeight} onupdateads={() => displayAd = getFirstAdOfType('card')} />
61
65
 
62
66
  {#snippet prepend()}
63
- {#if displayAd}
67
+ {#if displayAd && getSplitTestVariantName(SplitTest.DisplayAdFormat) !== 'Inline'}
64
68
  <div class="ad">
65
- <Display campaign={displayAd} />
69
+ <Display campaign={displayAd} slim />
66
70
  </div>
67
71
  {/if}
68
72
  {/snippet}
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">
2
+ import { SplitTest } from '$lib/enums/SplitTest'
2
3
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
4
+ import { getSplitTestVariantName } from '$lib/splitTest'
3
5
  import { track } from '$lib/tracking'
4
6
  import type { TitleData } from '$lib/types/title'
5
7
  import Title from '../Title.svelte'
@@ -16,6 +18,6 @@
16
18
 
17
19
  <RailModal items={titles} {initialIndex} {onclose} onchange={(index) => track(TrackingEvent.ExploreTitleRailSetIndex, titles[index], { index })} {...restProps}>
18
20
  {#snippet each(title, currentIndex)}
19
- <Title {title} useVideoBackground={title.sid === titles[currentIndex]?.sid} />
21
+ <Title {title} useVideoBackground={title.sid === titles[currentIndex]?.sid} useDisplayAdSplitTest={getSplitTestVariantName(SplitTest.DisplayAdFormat) === 'Inline'} />
20
22
  {/snippet}
21
23
  </RailModal>
@@ -7,11 +7,14 @@
7
7
  import type { TitleData } from '$lib/types/title'
8
8
  import { heading } from '$lib/actions/heading'
9
9
  import { campaignToPlaylink, getFirstAdOfType } from '$lib/api/ads'
10
- import { getContext } from 'svelte'
10
+ import { getContext, type Snippet } from 'svelte'
11
11
  import Playlink from './Playlink.svelte'
12
12
  import Button from '../Button.svelte'
13
13
  import PlaylinksDisclaimer from './PlaylinksDisclaimer.svelte'
14
14
  import { getConfigValue } from '$lib/api/config'
15
+ import { getSplitTestVariantName } from '$lib/splitTest'
16
+ import { SplitTest } from '$lib/enums/SplitTest'
17
+ import Display from '../Ads/Display.svelte'
15
18
 
16
19
  type Category = PlaylinkCategory | '' | 'Other'
17
20
  type CategorizedPlaylinks = Partial<Record<Category, PlaylinkData[]>>
@@ -21,9 +24,10 @@
21
24
  playlinks: PlaylinkData[]
22
25
  title: TitleData
23
26
  limit?: number
27
+ children?: Snippet
24
28
  }
25
29
 
26
- const { playlinks, title, limit = 3 }: Props = $props()
30
+ const { playlinks, title, limit = 3, children }: Props = $props()
27
31
 
28
32
  const isModal = getContext('scope') === 'modal'
29
33
  const type = getContext('type')
@@ -94,7 +98,11 @@
94
98
 
95
99
  <!-- A fake highlighted playlink as part of the display ad, to be shown after the first playlink -->
96
100
  {#if displayAd && (index === 0)}
97
- <Playlink playlink={campaignToPlaylink(displayAd)} onclick={() => track(TrackingEvent.DisplayedAdPlaylickClick, title, { campaign_name: displayAd.campaign_name })} hideCategory disclaimer={displayAd.disclaimer || ''} />
101
+ {#if children}
102
+ {@render children()}
103
+ {:else}
104
+ <Playlink playlink={campaignToPlaylink(displayAd)} onclick={() => track(TrackingEvent.DisplayedAdPlaylickClick, title, { campaign_name: displayAd.campaign_name })} hideCategory disclaimer={displayAd.disclaimer || ''} />
105
+ {/if}
98
106
  {/if}
99
107
  {/each}
100
108
  </div>
@@ -14,14 +14,18 @@
14
14
  import { TrackingEvent } from '$lib/enums/TrackingEvent'
15
15
  import TitleBackground from './TitleBackground.svelte'
16
16
  import TitleInfo from './TitleInfo.svelte'
17
+ import Display from './Ads/Display.svelte'
18
+ import type { Campaign } from '$lib/types/campaign'
19
+ import { getFirstAdOfType } from '$lib/api/ads'
17
20
 
18
21
  interface Props {
19
22
  title: TitleData
20
23
  small?: boolean
21
24
  useVideoBackground?: boolean
25
+ useDisplayAdSplitTest?: boolean // NOTE: Temporary split test, remove me after the DisplayAdFormat split test is gone
22
26
  }
23
27
 
24
- const { title, small = false, useVideoBackground = true }: Props = $props()
28
+ const { title, small = false, useVideoBackground = true, useDisplayAdSplitTest = false }: Props = $props()
25
29
 
26
30
  const noAffiliate = !!window.PlayPilotLinkInjections?.no_affiliate
27
31
 
@@ -58,7 +62,11 @@
58
62
  {/if}
59
63
 
60
64
  {#if !noAffiliate}
61
- <Playlinks playlinks={title.providers} {title} />
65
+ <Playlinks playlinks={title.providers} {title}>
66
+ {#if useDisplayAdSplitTest && getFirstAdOfType('card')}
67
+ <Display campaign={getFirstAdOfType('card')!} />
68
+ {/if}
69
+ </Playlinks>
62
70
  {/if}
63
71
 
64
72
  <ParticipantsRail {title} />
@@ -39,10 +39,21 @@
39
39
 
40
40
  // Used to re-render some elements with a key
41
41
  let renderKey = Math.random()
42
+
43
+ function insertMockAd(): void {
44
+ // @ts-ignore
45
+ window.PlayPilotLinkInjections.consents = {
46
+ ads: true
47
+ }
48
+
49
+ window.PlayPilotLinkInjections.ads = [campaign]
50
+ }
42
51
  </script>
43
52
 
44
53
  <h1>Elements</h1>
45
54
 
55
+ <button onclick={insertMockAd}>Insert mock ad</button>
56
+
46
57
  <p>This page lays out various elements used in TPI. It does not currently include editor elements.</p>
47
58
 
48
59
  <h2>Youtube Embed</h2>
@@ -173,7 +184,15 @@
173
184
  <div class="group">
174
185
  <div>
175
186
  <h3>Ads/Display.svelte</h3>
176
- <div class="item"><Display {campaign} /></div>
187
+ <div class="item">
188
+ <Display {campaign} />
189
+
190
+ Compact (Used in popover)
191
+ <Display {campaign} compact />
192
+
193
+ Slim (Used in rail modals)
194
+ <Display {campaign} slim />
195
+ </div>
177
196
  </div>
178
197
 
179
198
  <div>
@@ -1,156 +1,166 @@
1
- import { fireEvent, render } from '@testing-library/svelte'
2
- import { describe, expect, it, vi } from 'vitest'
3
-
4
- import Display from '../../../../routes/components/Ads/Display.svelte'
5
- import { track } from '$lib/tracking'
6
- import { TrackingEvent } from '$lib/enums/TrackingEvent'
7
-
8
- vi.mock('$lib/tracking', () => ({
9
- track: vi.fn(),
10
- }))
11
-
12
- export const campaign = {
13
- campaign_format: 'display',
14
- campaign_type: 'image',
15
- campaign_platforms: ['web', 'android_app', 'ios_app'],
16
- campaign_name: 'some_campaign_NL',
17
- campaign_start: '2025-04-24T00:00:00Z',
18
- campaign_end: '2025-04-30T23:59:00Z',
19
- campaign_region: 'nl',
20
- content: {
21
- header: 'Some top scroll header',
22
- header_logo: 'https://example.com/',
23
- header_logo_uuid: '4fb7d6ea152111f08dd20a58a9feac02',
24
- subheader: null,
25
- image: 'https://example.com/',
26
- image_uuid: '4fb7d6ea152111f08dd20a58a9feac02',
27
- video: null,
28
- format: null,
29
- },
30
- cta: {
31
- header: 'Button Label',
32
- subheader: null,
33
- image: null,
34
- image_uuid: null,
35
- url: 'https://google.com/',
36
- },
37
- content_playlist: null,
38
- provider: null,
39
- impression_trackers: [],
40
- target_title_uuid: null,
41
- target_title_sid: null,
42
- backfill_providers: [],
43
- autogenerated: false,
44
- enabled: true,
45
- hide_imdb_score: false,
46
- hide_sponsored_message: false,
47
- disclaimer: 'Some disclaimer',
48
- }
49
-
50
- describe('Display.svelte', () => {
51
- it('Should fire track event on mount', () => {
52
- /** @ts-ignore */
53
- render(Display, { campaign })
54
-
55
- expect(track).toHaveBeenCalledWith(TrackingEvent.DisplayAdView, null, { campaign_name: campaign.campaign_name })
56
- })
57
-
58
- it('Should fire track event on click', async () => {
59
- /** @ts-ignore */
60
- const { getByRole } = render(Display, { campaign })
61
-
62
- vi.resetAllMocks()
63
-
64
- await fireEvent.click(getByRole('link'))
65
- expect(track).toHaveBeenCalledWith(TrackingEvent.DisplayAdClick, null, { campaign_name: campaign.campaign_name })
66
- expect(track).toHaveBeenCalledTimes(1)
67
-
68
- await fireEvent.mouseUp(getByRole('link'), { button: 1 })
69
- expect(track).toHaveBeenCalledTimes(2)
70
- })
71
-
72
- it('Should render link without any content by default', () => {
73
- /** @ts-ignore */
74
- const { container } = render(Display, { campaign: { cta: {}, content: {} } })
75
-
76
- expect(/** @type {HTMLAnchorElement} */ (container.querySelector('a'))).toBeTruthy()
77
- expect(/** @type {HTMLAnchorElement} */ (container.querySelector('a')).children).toHaveLength(0)
78
- })
79
-
80
- it('Should render disclaimer when given', () => {
81
- /** @ts-ignore */
82
- const { getByTestId } = render(Display, { campaign: { disclaimer: 'Some disclaimer', cta: {}, content: {} } })
83
-
84
- expect(getByTestId('disclaimer')).toBeTruthy()
85
- })
86
-
87
- it('Should render content subheader when given', () => {
88
- /** @ts-ignore */
89
- const { getByText } = render(Display, { campaign: { cta: { subheader: 'Some cta subheader' }, content: { } } })
90
-
91
- expect(getByText('Some cta subheader')).toBeTruthy()
92
- })
93
-
94
- it('Should render logo when given', () => {
95
- /** @ts-ignore */
96
- const { getByRole } = render(Display, { campaign: { cta: {}, content: { header_logo: 'test' } } })
97
-
98
- expect(getByRole('presentation').getAttribute('src')).toBe('test')
99
- })
100
-
101
- it('Should render background image when given', () => {
102
- /** @ts-ignore */
103
- const { getByRole } = render(Display, { campaign: { campaign_type: 'image', cta: {}, content: { image: 'test' } } })
104
-
105
- expect(getByRole('presentation').getAttribute('src')).toBe('test')
106
- })
107
-
108
- it('Should render header when given', () => {
109
- /** @ts-ignore */
110
- const { getByText } = render(Display, { campaign: { cta: {}, content: { header: 'Some header' } } })
111
-
112
- expect(getByText('Some header')).toBeTruthy()
113
- })
114
-
115
- it('Should render subheader when given', () => {
116
- /** @ts-ignore */
117
- const { getByText } = render(Display, { campaign: { cta: {}, content: { header: 'Some subheader' } } })
118
-
119
- expect(getByText('Some subheader')).toBeTruthy()
120
- })
121
-
122
- it('Should render button when cta header is given', () => {
123
- /** @ts-ignore */
124
- const { getByText } = render(Display, { campaign: { cta: { header: 'Some button label' }, content: {} } })
125
-
126
- expect(getByText('Some button label')).toBeTruthy()
127
- })
128
-
129
- it('Should not have compact class by default', () => {
130
- /** @ts-ignore */
131
- const { getByRole } = render(Display, { campaign })
132
-
133
- expect(getByRole('link').classList).not.toContain('compact')
134
- })
135
-
136
- it('Should have compact class when prop is given', () => {
137
- /** @ts-ignore */
138
- const { getByRole } = render(Display, { campaign, compact: true })
139
-
140
- expect(getByRole('link').classList).toContain('compact')
141
- })
142
-
143
- it('Should not show disclaimer text when compact', () => {
144
- /** @ts-ignore */
145
- const { queryByText } = render(Display, { compact: true, campaign: { disclaimer: 'Some disclaimer', cta: {}, content: {} } })
146
-
147
- expect(queryByText('Some disclaimer')).not.toBeTruthy()
148
- })
149
-
150
- it('Should render video rather than image when video is given as type', () => {
151
- /** @ts-ignore */
152
- const { container } = render(Display, { campaign: { campaign_type: 'video', cta: {}, content: { video: 'abc' } } })
153
-
154
- expect(container.querySelector('video')).toBeTruthy()
155
- })
156
- })
1
+ import { fireEvent, render } from '@testing-library/svelte'
2
+ import { describe, expect, it, vi } from 'vitest'
3
+
4
+ import Display from '../../../../routes/components/Ads/Display.svelte'
5
+ import { track } from '$lib/tracking'
6
+ import { TrackingEvent } from '$lib/enums/TrackingEvent'
7
+
8
+ vi.mock('$lib/tracking', () => ({
9
+ track: vi.fn(),
10
+ }))
11
+
12
+ export const campaign = {
13
+ campaign_format: 'display',
14
+ campaign_type: 'image',
15
+ campaign_platforms: ['web', 'android_app', 'ios_app'],
16
+ campaign_name: 'some_campaign_NL',
17
+ campaign_start: '2025-04-24T00:00:00Z',
18
+ campaign_end: '2025-04-30T23:59:00Z',
19
+ campaign_region: 'nl',
20
+ content: {
21
+ header: 'Some top scroll header',
22
+ header_logo: 'https://example.com/',
23
+ header_logo_uuid: '4fb7d6ea152111f08dd20a58a9feac02',
24
+ subheader: null,
25
+ image: 'https://example.com/',
26
+ image_uuid: '4fb7d6ea152111f08dd20a58a9feac02',
27
+ video: null,
28
+ format: null,
29
+ },
30
+ cta: {
31
+ header: 'Button Label',
32
+ subheader: null,
33
+ image: null,
34
+ image_uuid: null,
35
+ url: 'https://google.com/',
36
+ },
37
+ content_playlist: null,
38
+ provider: null,
39
+ impression_trackers: [],
40
+ target_title_uuid: null,
41
+ target_title_sid: null,
42
+ backfill_providers: [],
43
+ autogenerated: false,
44
+ enabled: true,
45
+ hide_imdb_score: false,
46
+ hide_sponsored_message: false,
47
+ disclaimer: 'Some disclaimer',
48
+ }
49
+
50
+ describe('Display.svelte', () => {
51
+ it('Should fire track event on mount', () => {
52
+ /** @ts-ignore */
53
+ render(Display, { campaign })
54
+
55
+ expect(track).toHaveBeenCalledWith(TrackingEvent.DisplayAdView, null, { campaign_name: campaign.campaign_name })
56
+ })
57
+
58
+ it('Should fire track event on click', async () => {
59
+ /** @ts-ignore */
60
+ const { getByRole } = render(Display, { campaign })
61
+
62
+ vi.resetAllMocks()
63
+
64
+ await fireEvent.click(getByRole('link'))
65
+ expect(track).toHaveBeenCalledWith(TrackingEvent.DisplayAdClick, null, { campaign_name: campaign.campaign_name })
66
+ expect(track).toHaveBeenCalledTimes(1)
67
+
68
+ await fireEvent.mouseUp(getByRole('link'), { button: 1 })
69
+ expect(track).toHaveBeenCalledTimes(2)
70
+ })
71
+
72
+ it('Should render link without any content by default', () => {
73
+ /** @ts-ignore */
74
+ const { container } = render(Display, { campaign: { cta: {}, content: {} } })
75
+
76
+ expect(/** @type {HTMLAnchorElement} */ (container.querySelector('a'))).toBeTruthy()
77
+ expect(/** @type {HTMLAnchorElement} */ (container.querySelector('a')).children).toHaveLength(0)
78
+ })
79
+
80
+ it('Should render disclaimer when given', () => {
81
+ /** @ts-ignore */
82
+ const { getByTestId } = render(Display, { campaign: { disclaimer: 'Some disclaimer', cta: {}, content: {} } })
83
+
84
+ expect(getByTestId('disclaimer')).toBeTruthy()
85
+ })
86
+
87
+ it('Should render content subheader when given', () => {
88
+ /** @ts-ignore */
89
+ const { getByText } = render(Display, { campaign: { cta: { subheader: 'Some cta subheader' }, content: {} } })
90
+
91
+ expect(getByText('Some cta subheader')).toBeTruthy()
92
+ })
93
+
94
+ it('Should render logo when given', () => {
95
+ /** @ts-ignore */
96
+ const { getByRole } = render(Display, { campaign: { cta: {}, content: { header_logo: 'test' } } })
97
+
98
+ expect(getByRole('presentation').getAttribute('src')).toBe('test')
99
+ })
100
+
101
+ it('Should render background image when given', () => {
102
+ /** @ts-ignore */
103
+ const { getByRole } = render(Display, { campaign: { campaign_type: 'image', cta: {}, content: { image: 'test' } } })
104
+
105
+ expect(getByRole('presentation').getAttribute('src')).toBe('test')
106
+ })
107
+
108
+ it('Should render header when given', () => {
109
+ /** @ts-ignore */
110
+ const { getByText } = render(Display, { campaign: { cta: {}, content: { header: 'Some header' } } })
111
+
112
+ expect(getByText('Some header')).toBeTruthy()
113
+ })
114
+
115
+ it('Should render subheader when given', () => {
116
+ /** @ts-ignore */
117
+ const { getByText } = render(Display, { campaign: { cta: {}, content: { header: 'Some subheader' } } })
118
+
119
+ expect(getByText('Some subheader')).toBeTruthy()
120
+ })
121
+
122
+ it('Should render button when cta header is given', () => {
123
+ /** @ts-ignore */
124
+ const { getByText } = render(Display, { campaign: { cta: { header: 'Some button label' }, content: {} } })
125
+
126
+ expect(getByText('Some button label')).toBeTruthy()
127
+ })
128
+
129
+ it('Should not have compact class by default', () => {
130
+ /** @ts-ignore */
131
+ const { getByRole } = render(Display, { campaign })
132
+
133
+ expect(getByRole('link').classList).not.toContain('compact')
134
+ })
135
+
136
+ it('Should have compact class when prop is given', () => {
137
+ /** @ts-ignore */
138
+ const { getByRole } = render(Display, { campaign, compact: true })
139
+
140
+ expect(getByRole('link').classList).toContain('compact')
141
+ })
142
+
143
+ it('Should not show disclaimer text when compact', () => {
144
+ /** @ts-ignore */
145
+ const { queryByText } = render(Display, { compact: true, campaign: { disclaimer: 'Some disclaimer', cta: {}, content: {} } })
146
+
147
+ expect(queryByText('Some disclaimer')).not.toBeTruthy()
148
+ })
149
+
150
+ it('Should render video rather than image when video is given as type', () => {
151
+ /** @ts-ignore */
152
+ const { container } = render(Display, { campaign: { campaign_type: 'video', cta: {}, content: { video: 'abc' } } })
153
+
154
+ expect(container.querySelector('video')).toBeTruthy()
155
+ })
156
+
157
+ it('Should render with expected content when slim variant is given', () => {
158
+ /** @ts-ignore */
159
+ const { container, queryByText } = render(Display, { slim: true, campaign: { campaign_type: 'video', cta: { header: 'Some header', subheader: 'Some cta subheader' }, content: { header_logo: 'dfg', video: 'abc' } } })
160
+
161
+ expect(container.querySelector('.slim')).toBeTruthy()
162
+ expect(container.querySelector('.logo')).toBeTruthy()
163
+ expect(queryByText('Some header')).toBeTruthy()
164
+ expect(queryByText('Some cta header')).not.toBeTruthy()
165
+ })
166
+ })