mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 05:10:40 -07:00
29 lines
926 B
TypeScript
29 lines
926 B
TypeScript
import { getPerformance } from './performance'
|
|
|
|
describe('performance', () => {
|
|
let globalPerformance: Performance
|
|
beforeEach(() => {
|
|
globalPerformance = global.performance
|
|
})
|
|
afterEach(() => {
|
|
global.performance = globalPerformance
|
|
delete (global as any).window
|
|
})
|
|
it('should use global.performance if exist', () => {
|
|
const performance = {} as any as Performance
|
|
global.performance = performance
|
|
expect(getPerformance()).toEqual(performance)
|
|
})
|
|
it('should use window.performance if exist', () => {
|
|
const performance = {} as any as Performance
|
|
delete (global as any).performance
|
|
global.window = { performance } as any
|
|
expect(getPerformance()).toEqual(performance)
|
|
})
|
|
it('should use polyfill if no window/global.performance', () => {
|
|
delete (global as any).performance
|
|
const now = getPerformance().now()
|
|
expect(Number.isInteger(now)).toBeTruthy()
|
|
})
|
|
})
|