Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ describe('Hubspot Web (Actions)', () => {
expect(window.hbspt).toBeUndefined()
})

test('loads hubspot script with id=hs-script-loader to prevent duplicate script injection', async () => {
const [event] = await hubspotDestination({
portalId: '12345',
subscriptions
})

await event.load(Context.system(), {} as Analytics)

const loaderScripts = Array.from(document.querySelectorAll<HTMLScriptElement>('script#hs-script-loader'))
expect(loaderScripts).toHaveLength(1)
expect(loaderScripts[0].getAttribute('src')).toBe('https://js.hs-scripts.com/12345.js')
})
Comment thread
harsh-joshi99 marked this conversation as resolved.
Comment on lines +40 to +51

test('loads hubspot analytics with EU script', async () => {
const [event] = await hubspotDestination({
portalId: '12345',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const destination: BrowserDestinationDefinition<Settings, Hubspot> = {
? 'https://js-eu1.hsforms.net/forms/v2.js'
: 'https://js.hsforms.net/forms/v2.js'

await deps.loadScript(scriptPath)
await deps.loadScript(scriptPath, { id: 'hs-script-loader' })
Comment thread
harsh-joshi99 marked this conversation as resolved.
if (settings.loadFormsSDK) {
Comment thread
harsh-joshi99 marked this conversation as resolved.
await deps.loadScript(formsScriptPath)
}
Expand Down