-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow customizing the task scheduler.
Closes #17
- Loading branch information
1 parent
4e85c70
commit accdde5
Showing
8 changed files
with
109 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
scheduleTask, | ||
getTaskScheduler, | ||
setTaskScheduler, | ||
} from '../asynciterator.mjs'; | ||
|
||
describe('TaskScheduler', () => { | ||
describe('scheduleTask', () => { | ||
it('is a function', () => { | ||
expect(scheduleTask).to.be.an.instanceof(Function); | ||
}); | ||
|
||
it('schedules a task', done => { | ||
scheduleTask(done); | ||
}); | ||
}); | ||
|
||
describe('getTaskScheduler', () => { | ||
it('is a function', () => { | ||
expect(getTaskScheduler).to.be.an.instanceof(Function); | ||
}); | ||
|
||
it('returns a task scheduler', done => { | ||
const scheduler = getTaskScheduler(); | ||
scheduler(done); | ||
}); | ||
}); | ||
|
||
describe('setTaskScheduler', () => { | ||
it('is a function', () => { | ||
expect(setTaskScheduler).to.be.an.instanceof(Function); | ||
}); | ||
|
||
it('allows setting the task scheduler', () => { | ||
const scheduler = getTaskScheduler(); | ||
expect(getTaskScheduler()).to.equal(scheduler); | ||
|
||
const newScheduler = sinon.spy(); | ||
setTaskScheduler(newScheduler); | ||
expect(getTaskScheduler()).to.equal(newScheduler); | ||
expect(newScheduler).to.not.have.been.called; | ||
|
||
const task = sinon.spy(); | ||
scheduleTask(task); | ||
expect(newScheduler).to.have.been.calledOnce; | ||
expect(newScheduler).to.have.been.calledWith(task); | ||
|
||
setTaskScheduler(scheduler); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.