match-path-sync-tests.ts 628 B

1234567891011121314151617181920212223
  1. import { assert } from "chai";
  2. import { createMatchPath } from "../src/match-path-sync";
  3. import * as Tests from "./data/match-path-data";
  4. describe("match-path-sync", () => {
  5. Tests.tests.forEach(t =>
  6. it(t.name, () => {
  7. const matchPath = createMatchPath(
  8. t.absoluteBaseUrl,
  9. t.paths,
  10. t.mainFields,
  11. t.addMatchAll
  12. );
  13. const result = matchPath(
  14. t.requestedModule,
  15. (_: string) => t.packageJson,
  16. (name: string) => t.existingFiles.indexOf(name) !== -1, // fileExists
  17. t.extensions
  18. );
  19. assert.equal(result, t.expectedPath);
  20. })
  21. );
  22. });