source: trip-planner-front/node_modules/qjobs/tests/basic.js@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 490 bytes
RevLine 
[6a3a178]1#!/usr/bin/env node
2var assert = require('assert');
3var qjob = require('../qjobs');
4
5// only 2 jobs in the same time
6var q = new qjob({maxConcurrency:2});
7
8var testExecutedJobs = 0;
9
10var myjob = function(args,next) {
11 setTimeout(function() {
12 testExecutedJobs++;
13 next();
14 },50);
15}
16
17// Let's add 10 job and add them to the queue
18for (var i = 0; i<10; i++) {
19 q.add(myjob,['test'+i]);
20}
21
22q.on('end',function() {
23 assert.equal(testExecutedJobs, 10);
24});
25
26q.run();
27
28
Note: See TracBrowser for help on using the repository browser.