Files
fsevents/test/02_interleaved.js
8f00344899 remove static things from c-code (#342)
* Remove all static things

* Package Version Bump

* Expose since parameter

* Ammend ts declarations to allow since

* Add node8 and remove node13 from tests

Co-authored-by: Philipp Dunkel <[email protected]>
2020-11-03 12:51:12 +00:00

41 lines
1.3 KiB
JavaScript

const native = require("../fsevents.node");
const { mkdir, rm, touch, rename } = require("./utils/fs.js");
const { run, sleep } = require("./utils/misc.js");
const path = require("path");
const assert = require("assert");
const DIR = process.argv[2];
run(async () => {
await mkdir(`${DIR}/A`);
await mkdir(`${DIR}/B`);
await sleep(100);
const events = [];
const listenerA = native.start(native.global, `${DIR}/A`, native.flags.SinceNow, (...args) => events.push(args));
await touch(path.join(`${DIR}/A`, "created"));
await sleep(500);
const listenerB = native.start(native.global, `${DIR}/B`, native.flags.SinceNow, (...args) => events.push(args));
await sleep(500);
native.stop(listenerA);
await rename(path.join(`${DIR}/A`, "created"), path.join(`${DIR}/B`, "renamed"));
await sleep(500);
await rm(path.join(`${DIR}/B`, "renamed"));
await sleep(500);
native.stop(listenerB);
const expected = [
[path.join(`${DIR}/A`, "created"), 66816, 80865],
[path.join(`${DIR}/B`, "renamed"), 67584, 80888],
[path.join(`${DIR}/B`, "renamed"), 68096, 80910],
];
assert.equal(events.length, expected.length);
for (let idx = 0; idx < events.length; idx++) {
assert.equal(events[idx].length, expected[idx].length);
assert.equal(events[idx][0], expected[idx][0]);
assert.equal(events[idx][1], expected[idx][1]);
}
});