Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
qazsato committed Dec 3, 2024
1 parent 54a92b9 commit 5fd1ec0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tests/DebugView.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, expect, beforeEach, it } from '@jest/globals'
import { DebugView } from '../src/components/DebugView'
import { WebkitDeviceOrientationEvent } from '../src/maplibre-gl-compass'

describe('DebugView', () => {
let parentElement: HTMLElement
Expand All @@ -19,7 +20,12 @@ describe('DebugView', () => {
})

it('should update heading values', () => {
debugView.update('180.123')
debugView.update(180.123, {
type: 'deviceorientation',
alpha: 0,
beta: 0,
gamma: 0,
} as WebkitDeviceOrientationEvent)

const headingSpan = parentElement.querySelector('.heading')
expect(headingSpan?.textContent).toBe('180.123')
Expand All @@ -31,7 +37,14 @@ describe('DebugView', () => {

const updatedHeadingSpan = parentElement.querySelector('.heading')

expect(() => debugView.update('180.123')).not.toThrow()
expect(() =>
debugView.update(180.123, {
type: 'deviceorientation',
alpha: 0,
beta: 0,
gamma: 0,
} as WebkitDeviceOrientationEvent),
).not.toThrow()
expect(updatedHeadingSpan).toBeNull()
})
})

0 comments on commit 5fd1ec0

Please sign in to comment.