forked from github/browser-support
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequestidlecallback.js
More file actions
20 lines (18 loc) · 892 Bytes
/
requestidlecallback.js
File metadata and controls
20 lines (18 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import {expect} from 'chai'
import {apply, isPolyfilled, isSupported, requestIdleCallback} from '../src/requestidlecallback.ts'
describe('requestIdleCallback', () => {
it('has standard isSupported, isPolyfilled, apply API', () => {
expect(isSupported).to.be.a('function')
expect(isPolyfilled).to.be.a('function')
expect(apply).to.be.a('function')
expect(isSupported()).to.be.a('boolean')
expect(isPolyfilled()).to.equal(false)
})
it('resolves to first resolving value', async () => {
const arg = await new Promise(resolve => requestIdleCallback(resolve))
expect(Object.keys(arg)).to.eql(['didTimeout', 'timeRemaining'])
expect(arg).to.have.property('didTimeout').to.be.a('boolean')
expect(arg).to.have.property('timeRemaining').to.be.a('function')
expect(arg.timeRemaining()).to.be.a('number').lessThanOrEqual(50).greaterThanOrEqual(0)
})
})