Skip to content

Commit

Permalink
Add a test for the global debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
dobesv committed Sep 9, 2023
1 parent 80b77c2 commit 90d965e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/spawn/debounce-multi-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const tap = require('tap');

const { spawn, touchFile } = require('../utils');

tap.test('should reset debounce timer if a different file changes', t => {
spawn('--debounce=1000 --interval=50 server.js', out => {
if (out.match(/touch message.js/)) {
const ts = Date.now();
touchFile('server.js');
for (let i = 0; i <= 2000; i += 500) {
setTimeout(() => {
touchFile('message.js');
}, i);
}
return out2 => {
if (out2.match(/Restarting/)) {
if (Date.now() - ts < 2500) {
t.fail('Debounce logic did not wait 200 ms after the second change.');
}
return { exit: t.end.bind(t) };
}
};
}
});
});

0 comments on commit 90d965e

Please sign in to comment.