Skip to content

Commit

Permalink
test: css supports is not really testable :(
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieljablonski committed Feb 18, 2024
1 parent 0d5b88a commit 21909fc
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions src/test/utils.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debounce, computeTooltipPosition, cssTimeToMs, cssSupports } from 'utils'
import { debounce, computeTooltipPosition, cssTimeToMs } from 'utils'

// Tell Jest to mock all timeout functions
jest.useRealTimers()
Expand Down Expand Up @@ -86,35 +86,6 @@ describe('compute positions', () => {
})
})

describe('css supports', () => {
let windowSpy

beforeEach(() => {
windowSpy = jest.spyOn(window, 'window', 'get')
})

afterEach(() => {
windowSpy.mockRestore()
})

test('returns true if css property is supported', () => {
expect(cssSupports('position', 'relative')).toBe(true)
})

test('returns false if css property is not supported', () => {
expect(cssSupports('position', 'foo')).toBe(false)
})

test('returns true if `window.CSS.supports` is not available', () => {
windowSpy.mockImplementation(() => ({
CSS: {
supports: undefined,
},
}))
expect(cssSupports('position', 'foo')).toBe(true)
})
})

describe('css time to ms', () => {
test('converts time correctly', () => {
expect(cssTimeToMs('1s')).toBe(1000)
Expand Down

0 comments on commit 21909fc

Please sign in to comment.