Skip to content

Commit b7b857c

Browse files
committed
wip
1 parent 03b057d commit b7b857c

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

packages/signals/signals-runtime/bundle-build-tests/global.test.ts

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { JSDOM } from 'jsdom'
22
import fs from 'node:fs'
33
import 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+
})

packages/signals/signals/src/core/signal-generators/network-gen/__tests__/network-generator.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe(NetworkGenerator, () => {
150150
"data": "test",
151151
},
152152
"ok": true,
153-
"status": 200,
153+
"statusCode": 200,
154154
"url": "http://localhost/api",
155155
},
156156
"metadata": {
@@ -213,7 +213,7 @@ describe(NetworkGenerator, () => {
213213
"data": "test",
214214
},
215215
"ok": true,
216-
"status": 200,
216+
"statusCode": 200,
217217
"url": "http://localhost/test",
218218
},
219219
"metadata": {

packages/signals/signals/src/types/__tests__/create-network-signal.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe(createNetworkSignal, () => {
7474
"key": "value",
7575
},
7676
"ok": true,
77-
"status": 200,
77+
"statusCode": 200,
7878
"url": "http://example.com",
7979
},
8080
"metadata": {

0 commit comments

Comments
 (0)