Skip to content

Commit

Permalink
test: Add log prefix to UnityWebgl error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Marinerer committed Jan 17, 2025
1 parent b3c5646 commit 95f64e7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import UnityWebgl from '../lib/core/src/index'
import 'jest-canvas-mock'

const logPrefix = '[unity-webgl]'

// mock UnityInstance methods
const mockLoaderResult = jest.fn()
const mockSendMessage = jest.fn()
Expand Down Expand Up @@ -133,6 +135,7 @@ describe('UnityWebgl', () => {
unityWebgl.sendMessage('ObjectName', 'MethodName')

expect(consoleSpy).toHaveBeenCalledWith(
logPrefix,
'Unable to Send Message while Unity is not Instantiated.'
)

Expand All @@ -159,6 +162,7 @@ describe('UnityWebgl', () => {
unityWebgl.requestPointerLock()

expect(consoleSpy).toHaveBeenCalledWith(
logPrefix,
'Unable to requestPointerLock while Unity is not Instantiated.'
)

Expand Down Expand Up @@ -186,6 +190,7 @@ describe('UnityWebgl', () => {
unityWebgl.takeScreenshot()

expect(consoleSpy).toHaveBeenCalledWith(
logPrefix,
'Unable to take Screenshot while Unity is not Instantiated.'
)
consoleSpy.mockRestore()
Expand Down Expand Up @@ -213,6 +218,7 @@ describe('UnityWebgl', () => {
unityWebgl.setFullscreen(true)

expect(consoleSpy).toHaveBeenCalledWith(
logPrefix,
'Unable to set Fullscreen while Unity is not Instantiated.'
)

Expand Down

0 comments on commit 95f64e7

Please sign in to comment.