Skip to content

Commit 4933018

Browse files
committed
Add unit test for the buildAltText function
1 parent 19cf9ee commit 4933018

File tree

14 files changed

+689
-737
lines changed

14 files changed

+689
-737
lines changed

dist/chunk-5O7EAMJJ.js

Lines changed: 0 additions & 296 deletions
This file was deleted.

dist/chunk-7QWJQVKB.js

Lines changed: 296 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/chunk-GV27NAZY.mjs

Lines changed: 296 additions & 0 deletions
Large diffs are not rendered by default.

dist/chunk-XDQP7TXY.mjs

Lines changed: 0 additions & 296 deletions
This file was deleted.

dist/core.d.ts

Lines changed: 3 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -33,46 +33,6 @@ type AdCallbacks = {
3333
*/
3434
report?: string | null;
3535
};
36-
/**
37-
* An object containing attribution configuration for enabled ads.
38-
*/
39-
type Attributions = {
40-
/**
41-
* Advertising partner associated with the ad.
42-
*/
43-
partner_id: string;
44-
conversion?: Task;
45-
};
46-
type Task = {
47-
/**
48-
* DAP task ID.
49-
*/
50-
task_id: string;
51-
/**
52-
* DAP data type of the task.
53-
*/
54-
vdaf: string;
55-
/**
56-
* DAP data size of the task.
57-
*/
58-
bits?: number;
59-
/**
60-
* DAP legnth of the task.
61-
*/
62-
length: number;
63-
/**
64-
* DAP time precision. Determines rounding of dates in DAP report.
65-
*/
66-
time_precision: number;
67-
/**
68-
* Measurement to be used when a default report is sent.
69-
*/
70-
default_measurement?: number;
71-
/**
72-
* Index allocated to be used when a non-default report is sent.
73-
*/
74-
index: number;
75-
};
7636
type AdFormatBase = {
7737
/**
7838
* The format type of the ad.
@@ -83,7 +43,6 @@ type AdFormatBase = {
8343
*/
8444
url?: string;
8545
callbacks?: AdCallbacks;
86-
attributions?: Attributions;
8746
};
8847
/**
8948
* Client-side enforced frequency capping information.
@@ -181,42 +140,6 @@ type AdResponse = {
181140
[key: string]: Array<ImageAd | Spoc | UaTile>;
182141
};
183142

184-
declare global {
185-
var __gpp: GPPFunction | undefined;
186-
}
187-
interface GPPCommand {
188-
addEventListener: GPPAddEventListenerCallback;
189-
getField: GPPGetFieldCallback;
190-
getSection: GPPGetSectionCallback;
191-
hasSection: GPPHasSectionCallback;
192-
ping: GPPPingCallback;
193-
removeEventListener: GPPRemoveEventListenerCallback;
194-
}
195-
type GPPAddEventListenerCallback = (data: GPPEvent, success: boolean) => void;
196-
type GPPGetFieldCallback = (data: unknown | null, success: boolean) => void;
197-
type GPPGetSectionCallback = (data: unknown[] | null, success: boolean) => void;
198-
type GPPHasSectionCallback = (data: boolean, success: boolean) => void;
199-
type GPPPingCallback = (data: GPPPing, success: boolean) => void;
200-
type GPPRemoveEventListenerCallback = (data: boolean, success: boolean) => void;
201-
interface GPPEvent {
202-
eventName: string;
203-
listenerId: number;
204-
data: unknown;
205-
pingData: GPPPing;
206-
}
207-
interface GPPPing {
208-
gppVersion: string;
209-
cmpStatus: string;
210-
cmpDisplayStatus: string;
211-
signalStatus: string;
212-
supportedAPIs: string[];
213-
cmpId: number;
214-
sectionList: number[];
215-
applicableSections: number[];
216-
gppString: string;
217-
parsedSections: Record<string, unknown[]>;
218-
}
219-
type GPPFunction = <K extends keyof GPPCommand>(command: K, callback: GPPCommand[K], parameter?: unknown, version?: string) => void;
220143
type IABAdUnitFormatType = "Billboard" | "SmartphoneBanner300" | "SmartphoneBanner320" | "Leaderboard" | "SuperLeaderboardPushdown" | "Portrait" | "Skyscraper" | "MediumRectangle" | "TwentyBySixty" | "MobilePhoneInterstitial640" | "MobilePhoneInterstitial750" | "MobilePhoneInterstitial1080" | "FeaturePhoneSmallBanner" | "FeaturePhoneMediumBanner" | "FeaturePhoneLargeBanner";
221144
type NonIABAdUnitFormatType = "NewTab";
222145
type AdUnitFormatType = IABAdUnitFormatType | NonIABAdUnitFormatType;
@@ -264,15 +187,6 @@ interface MozAdsSize {
264187

265188
declare function recordClick(placement: MozAdsPlacementWithContent): Promise<void>;
266189

267-
interface MozAdsConfig {
268-
gppEnabled: boolean;
269-
gppReadyTimeout: number;
270-
}
271-
declare function getConfig(): MozAdsConfig;
272-
declare function setConfig(newConfig: Partial<MozAdsConfig>): void;
273-
declare function getConfigValue<K extends keyof MozAdsConfig>(key: K): MozAdsConfig[K];
274-
declare function setConfigValue<K extends keyof MozAdsConfig>(key: K, value: MozAdsConfig[K]): void;
275-
276190
declare const IS_BROWSER: boolean;
277191
declare const IS_PRODUCTION: boolean;
278192
declare const DEFAULT_SERVICE_ENDPOINT: HTTPSURLString;
@@ -295,6 +209,7 @@ interface MozAdsRenderPlacementProps {
295209
onLoad?: (event: MozAdsRenderPlacementEvent) => void;
296210
}
297211
declare function preloadImage(imageUrl: string): Promise<HTMLImageElement>;
212+
declare function buildAltText(placementId: string, altText: string | undefined): string;
298213
declare function renderPlacement(element: HTMLElement, { placement, onClick, onError, onLoad, onReport }: MozAdsRenderPlacementProps): void;
299214

300215
declare class FetchAdsError extends Error {
@@ -423,7 +338,7 @@ declare class DefaultLogReporter implements LogReporter {
423338
}
424339
declare const defaultLogReporter: DefaultLogReporter;
425340

426-
type MozAdsLocalizedStringKey = "ad_image_default_alt" | "alt_prefix_billboard_ad_image" | "alt_prefix_rectangle_ad_image" | "alt_prefix_skyscraper_ad_image" | "loading_spinner_tooltip" | "report_ad_button_tooltip" | "report_form_close_button_tooltip" | "report_form_select_reason_option_none" | "report_form_select_reason_option_inappropriate" | "report_form_select_reason_option_seen_too_many_times" | "report_form_select_reason_option_not_interested" | "report_form_submit_button" | "report_form_title_default" | "report_form_title_success";
341+
type MozAdsLocalizedStringKey = "alt_prefix_billboard_ad_image" | "alt_prefix_default_ad_image" | "alt_prefix_rectangle_ad_image" | "alt_prefix_skyscraper_ad_image" | "loading_spinner_tooltip" | "report_ad_button_tooltip" | "report_form_close_button_tooltip" | "report_form_select_reason_option_none" | "report_form_select_reason_option_inappropriate" | "report_form_select_reason_option_seen_too_many_times" | "report_form_select_reason_option_not_interested" | "report_form_submit_button" | "report_form_title_default" | "report_form_title_success";
427342
declare function l(key: MozAdsLocalizedStringKey): string;
428343

429344
declare enum LoggerLevel {
@@ -480,4 +395,4 @@ declare const setItemInStore: (key: MozAdsStoreKey, value: string, storeType?: S
480395
declare const removeItemFromStore: (key: MozAdsStoreKey, storeType?: StoreType) => void;
481396
declare const getOrGenerateContextId: (forceRegenerate?: boolean) => string;
482397

483-
export { AdUnitFormatImpressionThreshold, type AdUnitFormatType, AdUnitFormatTypeLookup, type AdUnitFormatTypeLookupKey, CLOSE_ICON_SVG, DEFAULT_SERVICE_ENDPOINT, DefaultImpressionThreshold, DefaultLogReporter, type DefaultLogReporterConfig, DefaultLogger, DefaultMozAdsImpressionObserver, FALLBACK_BILLBOARD_SVG, FALLBACK_DINO_SVG_FRAGMENT, FALLBACK_DONATE_SVG_FRAGMENT, FALLBACK_MRECTANGLE_SVG, FALLBACK_SKYSCRAPER_SVG, FallbackAdURL, FetchAdsError, type FetchAdsParams, FixedSize, type GPPAddEventListenerCallback, type GPPCommand, type GPPEvent, type GPPFunction, type GPPGetFieldCallback, type GPPGetSectionCallback, type GPPHasSectionCallback, type GPPPing, type GPPPingCallback, type GPPRemoveEventListenerCallback, type HTTPSURLString, type HttpRequestMethod, type IABAdUnitFormatType, type IABContent, type IABContentTaxonomyType, IABFixedSize, INSTRUMENT_ENDPOINT, IS_BROWSER, IS_PRODUCTION, type ImpressionThreshold, LOG_EMIT_FLAG_DEFAULT, LOG_TO_CONSOLE_FLAG_DEFAULT, type LogEmitterOptions, type LogFields, type LogReporter, type LogType, type Logger, type LoggerConfig, LoggerLevel, type MozAdsConfig, type MozAdsContent, type MozAdsImpressionObserver, type MozAdsImpressionTracker, type MozAdsLocalizedStringKey, type MozAdsPlacementConfig, type MozAdsPlacementWithContent, type MozAdsPlacements, type MozAdsRenderPlacementErrorEvent, type MozAdsRenderPlacementEvent, type MozAdsRenderPlacementProps, type MozAdsRenderPlacementReportEvent, type MozAdsSize, type MozAdsStoreKey, type MozLogMessage, type NonIABAdUnitFormatType, NonIABFixedSize, type PlacementImpressionInfo, REPORT_ICON_SVG, SeverityLevel, StoreType, type TelemetryEventLabel, buildPlacementsRequest, defaultImpressionObserver, defaultLogReporter, fetchAds, getConfig, getConfigValue, getItemFromStore, getOrGenerateContextId, l, mapResponseToPlacementsWithContent, preloadImage, recordClick, removeItemFromStore, renderPlacement, setConfig, setConfigValue, setItemInStore };
398+
export { AdUnitFormatImpressionThreshold, type AdUnitFormatType, AdUnitFormatTypeLookup, type AdUnitFormatTypeLookupKey, CLOSE_ICON_SVG, DEFAULT_SERVICE_ENDPOINT, DefaultImpressionThreshold, DefaultLogReporter, type DefaultLogReporterConfig, DefaultLogger, DefaultMozAdsImpressionObserver, FALLBACK_BILLBOARD_SVG, FALLBACK_DINO_SVG_FRAGMENT, FALLBACK_DONATE_SVG_FRAGMENT, FALLBACK_MRECTANGLE_SVG, FALLBACK_SKYSCRAPER_SVG, FallbackAdURL, FetchAdsError, type FetchAdsParams, FixedSize, type HTTPSURLString, type HttpRequestMethod, type IABAdUnitFormatType, type IABContent, type IABContentTaxonomyType, IABFixedSize, INSTRUMENT_ENDPOINT, IS_BROWSER, IS_PRODUCTION, type ImpressionThreshold, LOG_EMIT_FLAG_DEFAULT, LOG_TO_CONSOLE_FLAG_DEFAULT, type LogEmitterOptions, type LogFields, type LogReporter, type LogType, type Logger, type LoggerConfig, LoggerLevel, type MozAdsContent, type MozAdsImpressionObserver, type MozAdsImpressionTracker, type MozAdsLocalizedStringKey, type MozAdsPlacementConfig, type MozAdsPlacementWithContent, type MozAdsPlacements, type MozAdsRenderPlacementErrorEvent, type MozAdsRenderPlacementEvent, type MozAdsRenderPlacementProps, type MozAdsRenderPlacementReportEvent, type MozAdsSize, type MozAdsStoreKey, type MozLogMessage, type NonIABAdUnitFormatType, NonIABFixedSize, type PlacementImpressionInfo, REPORT_ICON_SVG, SeverityLevel, StoreType, type TelemetryEventLabel, buildAltText, buildPlacementsRequest, defaultImpressionObserver, defaultLogReporter, fetchAds, getItemFromStore, getOrGenerateContextId, l, mapResponseToPlacementsWithContent, preloadImage, recordClick, removeItemFromStore, renderPlacement, setItemInStore };

dist/core.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import{A as z,B as A,C as B,D as C,E as D,F as E,G as F,H as G,I as H,J as I,K as J,L as K,M as L,N as M,O as N,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,v as s,w as u,x as v,y as w,z as y}from"./chunk-XDQP7TXY.mjs";import"./chunk-57T3EAOB.mjs";export{d as AdUnitFormatImpressionThreshold,b as AdUnitFormatTypeLookup,h as CLOSE_ICON_SVG,e as DEFAULT_SERVICE_ENDPOINT,g as DefaultImpressionThreshold,u as DefaultLogReporter,y as DefaultLogger,z as DefaultMozAdsImpressionObserver,l as FALLBACK_BILLBOARD_SVG,j as FALLBACK_DINO_SVG_FRAGMENT,k as FALLBACK_DONATE_SVG_FRAGMENT,q as FALLBACK_MRECTANGLE_SVG,n as FALLBACK_SKYSCRAPER_SVG,c as FallbackAdURL,K as FetchAdsError,a as FixedSize,t as IABFixedSize,f as INSTRUMENT_ENDPOINT,o as IS_BROWSER,r as IS_PRODUCTION,p as LOG_EMIT_FLAG_DEFAULT,m as LOG_TO_CONSOLE_FLAG_DEFAULT,w as LoggerLevel,x as NonIABFixedSize,i as REPORT_ICON_SVG,s as SeverityLevel,F as StoreType,M as buildPlacementsRequest,A as defaultImpressionObserver,v as defaultLogReporter,L as fetchAds,G as getItemFromStore,J as getOrGenerateContextId,C as l,N as mapResponseToPlacementsWithContent,D as preloadImage,B as recordClick,I as removeItemFromStore,E as renderPlacement,H as setItemInStore};
1+
import{A as z,B as A,C as B,D as C,E as D,F as E,G as F,H as G,I as H,J as I,K as J,L as K,M as L,N as M,O as N,P as O,a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a,j as b,k as c,l as d,m as g,n as h,o as i,p as j,q as k,r as l,s as n,t as q,v as s,w as u,x as v,y as w,z as y}from"./chunk-GV27NAZY.mjs";import"./chunk-57T3EAOB.mjs";export{d as AdUnitFormatImpressionThreshold,b as AdUnitFormatTypeLookup,h as CLOSE_ICON_SVG,e as DEFAULT_SERVICE_ENDPOINT,g as DefaultImpressionThreshold,u as DefaultLogReporter,y as DefaultLogger,z as DefaultMozAdsImpressionObserver,l as FALLBACK_BILLBOARD_SVG,j as FALLBACK_DINO_SVG_FRAGMENT,k as FALLBACK_DONATE_SVG_FRAGMENT,q as FALLBACK_MRECTANGLE_SVG,n as FALLBACK_SKYSCRAPER_SVG,c as FallbackAdURL,L as FetchAdsError,a as FixedSize,t as IABFixedSize,f as INSTRUMENT_ENDPOINT,o as IS_BROWSER,r as IS_PRODUCTION,p as LOG_EMIT_FLAG_DEFAULT,m as LOG_TO_CONSOLE_FLAG_DEFAULT,w as LoggerLevel,x as NonIABFixedSize,i as REPORT_ICON_SVG,s as SeverityLevel,G as StoreType,E as buildAltText,N as buildPlacementsRequest,A as defaultImpressionObserver,v as defaultLogReporter,M as fetchAds,H as getItemFromStore,K as getOrGenerateContextId,C as l,O as mapResponseToPlacementsWithContent,D as preloadImage,B as recordClick,J as removeItemFromStore,F as renderPlacement,I as setItemInStore};

0 commit comments

Comments
 (0)