"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const testing_1 = require("@angular-devkit/schematics/testing");
const schematics_1 = require("@angular-devkit/schematics");
const schematicRunner = new testing_1.SchematicTestRunner('schematics', path.join(__dirname, '../collection.json'));
const tmpNodeModules = path.resolve(__dirname, '__test__/node_modules/pdfjs-dist');
const testFilePath = path.join(tmpNodeModules, 'test-file.js');
const originalContent = `console.log('hello');\n/*webpackIgnore: true*/\n`;
describe('fix-webpack-ignore schematic', () => {
    let tree;
    beforeEach(() => {
        fs.rmSync(path.resolve(__dirname, '__test__'), { recursive: true, force: true });
        fs.mkdirSync(tmpNodeModules, { recursive: true });
        fs.writeFileSync(testFilePath, originalContent, 'utf8');
    });
    it('replaces webpackIgnore with @vite-ignore', async () => {
        const options = {
            package: 'pdfjs-dist',
            verbose: false,
            patchPackage: false
        };
        tree = await schematicRunner.runSchematic('fix-webpack-ignore', options, schematics_1.Tree.empty());
        const content = fs.readFileSync(testFilePath, 'utf8');
        expect(content).toContain('/* @vite-ignore */');
        expect(content).not.toContain('webpackIgnore');
    });
    it('does not touch files without the pattern', async () => {
        const cleanFilePath = path.join(tmpNodeModules, 'clean.js');
        const cleanContent = `console.log("no ignore here");\n`;
        fs.writeFileSync(cleanFilePath, cleanContent, 'utf8');
        const options = {
            package: 'pdfjs-dist',
            verbose: false,
            patchPackage: false
        };
        await schematicRunner.runSchematic('fix-webpack-ignore', options, schematics_1.Tree.empty());
        const after = fs.readFileSync(cleanFilePath, 'utf8');
        expect(after).toEqual(cleanContent);
    });
    afterEach(() => {
        fs.rmSync(path.resolve(__dirname, '__test__'), { recursive: true, force: true });
    });
});
//# sourceMappingURL=index.spec.js.map