job-test.js 647 B

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. module.exports = function(schedule) {
  3. return {
  4. jobInGenerator: function(test) {
  5. test.expect(1);
  6. var job = new schedule.Job(function*() {
  7. test.ok(true);
  8. });
  9. job.runOnDate(new Date(Date.now() + 3000));
  10. setTimeout(function() {
  11. test.done();
  12. }, 3250);
  13. },
  14. jobContextInGenerator: function(test) {
  15. test.expect(1);
  16. var job = new schedule.Job('name of job', function*() {
  17. test.ok(this.name === 'name of job');
  18. });
  19. job.runOnDate(new Date(Date.now() + 3000));
  20. setTimeout(function() {
  21. test.done();
  22. }, 3250);
  23. }
  24. }
  25. }