2024-11-03 17:41:45 +01:00

31 lines
1.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const test = require("ava");
const { find } = require("../main.js");
test("Empty", async t => {
t.deepEqual(await find("./test/stubs/empty.js"), []);
});
test("Doesnt exist", async t => {
t.deepEqual(await find("./test/stubs/THIS_FILE_DOES_NOT_EXIST.js"), []);
});
test("Simple", async t => {
t.deepEqual(await find("./test/stubs/file.js"), ["./test/stubs/imported-secondary.js"]);
});
test("Nested two deep", async t => {
t.deepEqual(await find("./test/stubs/nested.js"), ["./test/stubs/imported.js", "./test/stubs/imported-secondary.js"]);
});
test("Nested three deep", async t => {
t.deepEqual(await find("./test/stubs/nested-grandchild.js"), ["./test/stubs/nested.js", "./test/stubs/imported.js", "./test/stubs/imported-secondary.js"]);
});
test("Circular", async t => {
t.deepEqual(await find("./test/stubs/circular-parent.js"), ["./test/stubs/circular-child.js"]);
});
test("Circular Self Reference", async t => {
t.deepEqual(await find("./test/stubs/circular-self.js"), ["./test/stubs/empty.js"]);
});