update test
This commit is contained in:
@@ -17,15 +17,7 @@ const mockLog = {
|
|||||||
|
|
||||||
// Mock the logger import
|
// Mock the logger import
|
||||||
jest.mock('../../../scripts/modules/utils.js', () => ({
|
jest.mock('../../../scripts/modules/utils.js', () => ({
|
||||||
log: jest.fn((level, ...args) => {
|
log: (level, message) => mockLog[level]?.(message)
|
||||||
// Handle the log function more robustly to avoid JSON parsing issues in tests
|
|
||||||
const mockFn = mockLog[level] || jest.fn();
|
|
||||||
// Convert objects to strings safely for testing
|
|
||||||
const safeArgs = args.map(arg =>
|
|
||||||
typeof arg === 'object' ? '[Object]' : String(arg)
|
|
||||||
);
|
|
||||||
return mockFn(...safeArgs);
|
|
||||||
})
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('Selective Rules Removal', () => {
|
describe('Selective Rules Removal', () => {
|
||||||
@@ -36,10 +28,15 @@ describe('Selective Rules Removal', () => {
|
|||||||
let mockReadFileSync;
|
let mockReadFileSync;
|
||||||
let mockWriteFileSync;
|
let mockWriteFileSync;
|
||||||
let mockMkdirSync;
|
let mockMkdirSync;
|
||||||
|
let originalConsoleLog;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|
||||||
|
// Mock console.log to prevent JSON parsing issues in Jest
|
||||||
|
originalConsoleLog = console.log;
|
||||||
|
console.log = jest.fn();
|
||||||
|
|
||||||
// Create temp directory for testing
|
// Create temp directory for testing
|
||||||
tempDir = fs.mkdtempSync(path.join(process.cwd(), 'test-temp-'));
|
tempDir = fs.mkdtempSync(path.join(process.cwd(), 'test-temp-'));
|
||||||
|
|
||||||
@@ -55,6 +52,9 @@ describe('Selective Rules Removal', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
// Restore console.log
|
||||||
|
console.log = originalConsoleLog;
|
||||||
|
|
||||||
// Clean up temp directory
|
// Clean up temp directory
|
||||||
try {
|
try {
|
||||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user