File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change 1- import { debounce , computeTooltipPosition , cssTimeToMs } from 'utils'
1+ import { debounce , computeTooltipPosition , cssTimeToMs , cssSupports } from 'utils'
22
33// Tell Jest to mock all timeout functions
44jest . useRealTimers ( )
@@ -134,6 +134,35 @@ describe('debounce', () => {
134134 } )
135135} )
136136
137+ describe ( 'css supports' , ( ) => {
138+ let windowSpy
139+
140+ beforeEach ( ( ) => {
141+ windowSpy = jest . spyOn ( window , 'window' , 'get' )
142+ } )
143+
144+ afterEach ( ( ) => {
145+ windowSpy . mockRestore ( )
146+ } )
147+
148+ test ( 'returns true if css property is supported' , ( ) => {
149+ expect ( cssSupports ( 'position' , 'relative' ) ) . toBe ( true )
150+ } )
151+
152+ test ( 'returns false if css property is not supported' , ( ) => {
153+ expect ( cssSupports ( 'position' , 'foo' ) ) . toBe ( false )
154+ } )
155+
156+ test ( 'returns true if `window.CSS.supports` is not available' , ( ) => {
157+ windowSpy . mockImplementation ( ( ) => ( {
158+ CSS : {
159+ supports : undefined ,
160+ } ,
161+ } ) )
162+ expect ( cssSupports ( 'position' , 'foo' ) ) . toBe ( true )
163+ } )
164+ } )
165+
137166describe ( 'css time to ms' , ( ) => {
138167 test ( 'converts time correctly' , ( ) => {
139168 expect ( cssTimeToMs ( '1s' ) ) . toBe ( 1000 )
You can’t perform that action at this time.
0 commit comments