match-path-async-tests.ts 734 B

123456789101112131415161718192021222324252627
  1. import { assert } from "chai";
  2. import { createMatchPathAsync } from "../src/match-path-async";
  3. import * as Tests from "./data/match-path-data";
  4. describe("match-path-async", () => {
  5. Tests.tests.forEach(t =>
  6. it(t.name, done => {
  7. const matchPath = createMatchPathAsync(
  8. t.absoluteBaseUrl,
  9. t.paths,
  10. t.mainFields,
  11. t.addMatchAll
  12. );
  13. matchPath(
  14. t.requestedModule,
  15. (_path, callback) => callback(undefined, t.packageJson),
  16. (path, callback) =>
  17. callback(undefined, t.existingFiles.indexOf(path) !== -1),
  18. t.extensions,
  19. (_err, result) => {
  20. assert.equal(result, t.expectedPath);
  21. done();
  22. }
  23. );
  24. })
  25. );
  26. });