@@ -2,11 +2,11 @@ import { JSDOM } from 'jsdom'
22import fs from 'node:fs'
33import path from 'node:path'
44
5- describe ( 'Global Scope Test' , ( ) => {
5+ describe ( 'Global Scope Test: Web ' , ( ) => {
66 let dom : JSDOM
77 beforeAll ( ( ) => {
88 // Load the built file
9- const filePath = path . resolve ( __dirname , '../dist/global/index.mobile .js' )
9+ const filePath = path . resolve ( __dirname , '../dist/global/index.web .js' )
1010 const scriptContent = fs . readFileSync ( filePath , 'utf-8' )
1111
1212 // Create a new JSDOM instance
@@ -21,16 +21,49 @@ describe('Global Scope Test', () => {
2121 dom . window . document . head . appendChild ( scriptElement )
2222 } )
2323
24- test ( 'should expose SignalsRuntime in the global scope' , ( ) => {
24+ test ( 'should expose Signals in the global scope' , ( ) => {
2525 // @ts -ignore
2626 expect ( dom . window ) . toBeDefined ( )
2727 // @ts -ignore
28- expect ( typeof dom . window . SignalsRuntime ) . toBe ( 'function' )
28+ expect ( typeof dom . window . Signals ) . toBe ( 'function' )
2929 } )
3030
31- test ( 'should expose navigation actions ' , ( ) => {
31+ test ( 'should expose constants ' , ( ) => {
3232 expect ( dom . window . EventType . Track ) . toBe ( 'track' )
3333 expect ( dom . window . NavigationAction . URLChange ) . toBe ( 'urlChange' )
3434 expect ( dom . window . SignalType . Interaction ) . toBe ( 'interaction' )
3535 } )
3636} )
37+
38+ describe ( 'Global Scope Test: Mobile' , ( ) => {
39+ let dom : JSDOM
40+ beforeAll ( ( ) => {
41+ // Load the built file
42+ const filePath = path . resolve ( __dirname , '../dist/global/index.mobile.js' )
43+ const scriptContent = fs . readFileSync ( filePath , 'utf-8' )
44+
45+ // Create a new JSDOM instance
46+ dom = new JSDOM ( `<!DOCTYPE html><html><head></head><body></body></html>` , {
47+ runScripts : 'dangerously' ,
48+ resources : 'usable' ,
49+ } )
50+
51+ // Execute the script in the JSDOM context
52+ const scriptElement = dom . window . document . createElement ( 'script' )
53+ scriptElement . textContent = scriptContent
54+ dom . window . document . head . appendChild ( scriptElement )
55+ } )
56+
57+ test ( 'should expose Signals in the global scope' , ( ) => {
58+ // @ts -ignore
59+ expect ( dom . window ) . toBeDefined ( )
60+ // @ts -ignore
61+ expect ( typeof dom . window . Signals ) . toBe ( 'function' )
62+ } )
63+
64+ test ( 'should expose constants' , ( ) => {
65+ expect ( dom . window . EventType . Track ) . toBe ( 'track' )
66+ expect ( dom . window . NavigationAction . Forward ) . toBe ( 'forward' )
67+ expect ( dom . window . SignalType . Interaction ) . toBe ( 'interaction' )
68+ } )
69+ } )
0 commit comments