/**
 * Property-Based Tests for FP Filter
 *
 * Tests invariants of analyzeFilePath using fast-check property-based testing.
 *
 * @module __tests__/scanners/fp-filter.property
 */
import { describe, it } from "vitest";
import * as fc from "fast-check";
import { analyzeFilePath } from "../../scanners/fp-filter.js";
import { arbitraries, testFilePath, specFilePath, nodeModulesPath, generatedFilePath, dtsFilePath, } from "../property-test-helpers.js";
describe("analyzeFilePath - Property Tests", () => {
    describe("Return type invariants", () => {
        it("always returns all expected boolean keys", () => {
            fc.assert(fc.property(fc.string(), (path) => {
                const result = analyzeFilePath(path);
                return (typeof result.isTestFile === "boolean" &&
                    typeof result.isGeneratedCode === "boolean" &&
                    typeof result.isThirdPartyVendored === "boolean" &&
                    typeof result.isMockFile === "boolean" &&
                    typeof result.isFixtureFile === "boolean" &&
                    typeof result.isExampleFile === "boolean");
            }));
        });
        it("is idempotent - same input always produces same output", () => {
            fc.assert(fc.property(fc.string(), (path) => {
                const r1 = analyzeFilePath(path);
                const r2 = analyzeFilePath(path);
                return JSON.stringify(r1) === JSON.stringify(r2);
            }));
        });
    });
    describe("Test file detection", () => {
        it("*.test.ts files are always test files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = testFilePath(stem, "ts");
                const result = analyzeFilePath(path);
                return result.isTestFile === true;
            }));
        });
        it("*.test.tsx files are always test files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = `src/${stem}.test.tsx`;
                const result = analyzeFilePath(path);
                return result.isTestFile === true;
            }));
        });
        it("*.spec.ts files are always test files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = specFilePath(stem, "ts");
                const result = analyzeFilePath(path);
                return result.isTestFile === true;
            }));
        });
        it("*.spec.js files are always test files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = specFilePath(stem, "js");
                const result = analyzeFilePath(path);
                return result.isTestFile === true;
            }));
        });
        it("files in __tests__ directory are always test files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, arbitraries.fileExtension, (filename, ext) => {
                const path = `src/__tests__/${filename}.${ext}`;
                const result = analyzeFilePath(path);
                return result.isTestFile === true;
            }));
        });
        it("files in cypress directory are always test files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `cypress/e2e/${filename}.cy.ts`;
                const result = analyzeFilePath(path);
                return result.isTestFile === true;
            }));
        });
        it("regular source files are not test files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = `src/components/${stem}.ts`;
                const result = analyzeFilePath(path);
                return result.isTestFile === false;
            }));
        });
    });
    describe("Vendor/third-party detection", () => {
        it("node_modules paths are always vendored", () => {
            fc.assert(fc.property(arbitraries.pathSegment, arbitraries.pathSegment, (pkg, file) => {
                const path = nodeModulesPath(pkg, file);
                const result = analyzeFilePath(path);
                return result.isThirdPartyVendored === true;
            }));
        });
        it("vendor directory paths are always vendored", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (file) => {
                const path = `vendor/libs/${file}.js`;
                const result = analyzeFilePath(path);
                return result.isThirdPartyVendored === true;
            }));
        });
        it("third_party directory paths are always vendored", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (file) => {
                const path = `third_party/${file}.js`;
                const result = analyzeFilePath(path);
                return result.isThirdPartyVendored === true;
            }));
        });
        it("*.min.js files are always vendored", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = `libs/${stem}.min.js`;
                const result = analyzeFilePath(path);
                return result.isThirdPartyVendored === true;
            }));
        });
        it("regular source files are not vendored", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = `src/utils/${stem}.ts`;
                const result = analyzeFilePath(path);
                return result.isThirdPartyVendored === false;
            }));
        });
    });
    describe("Generated code detection", () => {
        it("*.generated.ts files are always generated", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = generatedFilePath(stem);
                const result = analyzeFilePath(path);
                return result.isGeneratedCode === true;
            }));
        });
        it("*.d.ts files are always generated", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = dtsFilePath(stem);
                const result = analyzeFilePath(path);
                return result.isGeneratedCode === true;
            }));
        });
        it("files in __generated__ directory are always generated", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `src/__generated__/${filename}.ts`;
                const result = analyzeFilePath(path);
                return result.isGeneratedCode === true;
            }));
        });
        it("prisma/client paths are always generated", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (file) => {
                const path = `node_modules/prisma/client/${file}.ts`;
                const result = analyzeFilePath(path);
                return result.isGeneratedCode === true;
            }));
        });
        it("regular source files are not generated", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = `src/services/${stem}.ts`;
                const result = analyzeFilePath(path);
                return result.isGeneratedCode === false;
            }));
        });
    });
    describe("Mock file detection", () => {
        it("*.mock.ts files are always mock files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (stem) => {
                const path = `src/${stem}.mock.ts`;
                const result = analyzeFilePath(path);
                return result.isMockFile === true;
            }));
        });
        it("files in __mocks__ directory are test files (via TEST_FILE_PATTERNS)", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `src/__mocks__/${filename}.ts`;
                const result = analyzeFilePath(path);
                // __mocks__ triggers isTestFile via TEST_FILE_PATTERNS
                return result.isTestFile === true;
            }));
        });
        it("files in mocks directory are mock files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `src/mocks/${filename}.ts`;
                const result = analyzeFilePath(path);
                return result.isMockFile === true;
            }));
        });
    });
    describe("Fixture file detection", () => {
        it("files in fixtures directory are fixture files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `src/fixtures/${filename}.json`;
                const result = analyzeFilePath(path);
                return result.isFixtureFile === true;
            }));
        });
        it("files in samples directory are fixture files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `data/samples/${filename}.json`;
                const result = analyzeFilePath(path);
                return result.isFixtureFile === true;
            }));
        });
        it("files in seed directory are fixture files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `db/seed/${filename}.ts`;
                const result = analyzeFilePath(path);
                return result.isFixtureFile === true;
            }));
        });
    });
    describe("Example file detection", () => {
        it("files in examples directory are example files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `examples/${filename}.ts`;
                const result = analyzeFilePath(path);
                return result.isExampleFile === true;
            }));
        });
        it("files in demo directory are example files", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const path = `demo/${filename}.ts`;
                const result = analyzeFilePath(path);
                return result.isExampleFile === true;
            }));
        });
    });
    describe("Path normalization", () => {
        it("handles backslash paths consistently (Windows style)", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const unixPath = `src/__tests__/${filename}.test.ts`;
                const windowsPath = `src\\__tests__\\${filename}.test.ts`;
                const result1 = analyzeFilePath(unixPath);
                const result2 = analyzeFilePath(windowsPath);
                return JSON.stringify(result1) === JSON.stringify(result2);
            }));
        });
        it("handles mixed slash paths", () => {
            fc.assert(fc.property(arbitraries.pathSegment, (filename) => {
                const mixedPath = `src\\__tests__/${filename}.test.ts`;
                const result = analyzeFilePath(mixedPath);
                return result.isTestFile === true;
            }));
        });
    });
    describe("Classification exclusivity", () => {
        it("vendored files are not classified as regular test files", () => {
            // A file in node_modules with .test.ts extension
            // Both classifications may be true, but let's check they don't conflict
            fc.assert(fc.property(arbitraries.pathSegment, (pkg) => {
                const path = `node_modules/${pkg}/index.test.ts`;
                const result = analyzeFilePath(path);
                // Both can be true - this is expected behavior
                // The point is that vendored takes precedence in filtering
                return result.isThirdPartyVendored === true;
            }));
        });
    });
});
//# sourceMappingURL=fp-filter.property.test.js.map