fix formatting

This commit is contained in:
Joe Danziger
2025-05-09 12:21:51 -04:00
parent 476048b184
commit d48a3d3edc
7 changed files with 129 additions and 91 deletions

View File

@@ -8,66 +8,71 @@ import path from 'path';
// Mock logger
const mockLogger = {
info: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
debug: jest.fn()
info: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
debug: jest.fn()
};
// Use a temp directory for testing (simulate a project root)
const tempProjectRoot = path.join(__dirname, '../../fixtures/temp-rules-project');
const tempProjectRoot = path.join(
__dirname,
'../../fixtures/temp-rules-project'
);
beforeAll(() => {
if (!fs.existsSync(tempProjectRoot)) fs.mkdirSync(tempProjectRoot, { recursive: true });
if (!fs.existsSync(tempProjectRoot))
fs.mkdirSync(tempProjectRoot, { recursive: true });
});
afterAll(() => {
if (fs.existsSync(tempProjectRoot)) fs.rmSync(tempProjectRoot, { recursive: true, force: true });
if (fs.existsSync(tempProjectRoot))
fs.rmSync(tempProjectRoot, { recursive: true, force: true });
});
describe('rulesDirect (integration)', () => {
it('should add brand rules successfully', async () => {
const args = {
action: 'add',
rules: ['roo'],
projectRoot: tempProjectRoot,
yes: true
};
const result = await rulesDirect(args, mockLogger, {});
expect(result.success).toBe(true);
expect(result.data.output).toMatch(/add|roo/i);
});
it('should add brand rules successfully', async () => {
const args = {
action: 'add',
rules: ['roo'],
projectRoot: tempProjectRoot,
yes: true
};
const result = await rulesDirect(args, mockLogger, {});
expect(result.success).toBe(true);
expect(result.data.output).toMatch(/add|roo/i);
});
it('should remove brand rules successfully', async () => {
const args = {
action: 'remove',
rules: ['roo'],
projectRoot: tempProjectRoot,
yes: true
};
const result = await rulesDirect(args, mockLogger, {});
expect(result.success).toBe(true);
expect(result.data.output).toMatch(/remove|roo/i);
});
it('should remove brand rules successfully', async () => {
const args = {
action: 'remove',
rules: ['roo'],
projectRoot: tempProjectRoot,
yes: true
};
const result = await rulesDirect(args, mockLogger, {});
expect(result.success).toBe(true);
expect(result.data.output).toMatch(/remove|roo/i);
});
it('should fail if missing required arguments', async () => {
const args = {
action: 'add',
rules: [], // missing brands
projectRoot: tempProjectRoot
};
const result = await rulesDirect(args, mockLogger, {});
expect(result.success).toBe(false);
expect(result.error.code).toBe('MISSING_ARGUMENT');
});
it('should fail if missing required arguments', async () => {
const args = {
action: 'add',
rules: [], // missing brands
projectRoot: tempProjectRoot
};
const result = await rulesDirect(args, mockLogger, {});
expect(result.success).toBe(false);
expect(result.error.code).toBe('MISSING_ARGUMENT');
});
it('should fail if projectRoot is missing', async () => {
const args = {
action: 'add',
rules: ['roo']
};
const result = await rulesDirect(args, mockLogger, {});
expect(result.success).toBe(false);
expect(result.error.code).toBe('MISSING_ARGUMENT');
});
it('should fail if projectRoot is missing', async () => {
const args = {
action: 'add',
rules: ['roo']
};
const result = await rulesDirect(args, mockLogger, {});
expect(result.success).toBe(false);
expect(result.error.code).toBe('MISSING_ARGUMENT');
});
});