80 lines
3.2 KiB
JavaScript
80 lines
3.2 KiB
JavaScript
const index = require('./index');
|
|
|
|
describe('eslint-rules index', () => {
|
|
describe('rules', () => {
|
|
it('should export no-index-files rule', () => {
|
|
expect(index.rules['no-index-files']).toBeDefined();
|
|
expect(index.rules['no-index-files'].meta).toBeDefined();
|
|
expect(index.rules['no-index-files'].create).toBeDefined();
|
|
});
|
|
|
|
it('should export no-framework-imports rule', () => {
|
|
expect(index.rules['no-framework-imports']).toBeDefined();
|
|
expect(index.rules['no-framework-imports'].meta).toBeDefined();
|
|
expect(index.rules['no-framework-imports'].create).toBeDefined();
|
|
});
|
|
|
|
it('should export domain-no-application rule', () => {
|
|
expect(index.rules['domain-no-application']).toBeDefined();
|
|
expect(index.rules['domain-no-application'].meta).toBeDefined();
|
|
expect(index.rules['domain-no-application'].create).toBeDefined();
|
|
});
|
|
|
|
it('should have exactly 3 rules', () => {
|
|
expect(Object.keys(index.rules)).toHaveLength(3);
|
|
});
|
|
});
|
|
|
|
describe('configs', () => {
|
|
it('should export recommended config', () => {
|
|
expect(index.configs.recommended).toBeDefined();
|
|
});
|
|
|
|
it('recommended config should have gridpilot-core-rules plugin', () => {
|
|
expect(index.configs.recommended.plugins).toContain('gridpilot-core-rules');
|
|
});
|
|
|
|
it('recommended config should enable all rules', () => {
|
|
expect(index.configs.recommended.rules['gridpilot-core-rules/no-index-files']).toBe('error');
|
|
expect(index.configs.recommended.rules['gridpilot-core-rules/no-framework-imports']).toBe('error');
|
|
expect(index.configs.recommended.rules['gridpilot-core-rules/domain-no-application']).toBe('error');
|
|
});
|
|
|
|
it('recommended config should have exactly 3 rules', () => {
|
|
expect(Object.keys(index.configs.recommended.rules)).toHaveLength(3);
|
|
});
|
|
});
|
|
|
|
describe('rule metadata', () => {
|
|
it('no-index-files should have correct metadata', () => {
|
|
const rule = index.rules['no-index-files'];
|
|
expect(rule.meta.type).toBe('problem');
|
|
expect(rule.meta.docs.category).toBe('Best Practices');
|
|
expect(rule.meta.docs.recommended).toBe(true);
|
|
expect(rule.meta.fixable).toBe(null);
|
|
expect(rule.meta.schema).toEqual([]);
|
|
expect(rule.meta.messages.indexFile).toBeDefined();
|
|
});
|
|
|
|
it('no-framework-imports should have correct metadata', () => {
|
|
const rule = index.rules['no-framework-imports'];
|
|
expect(rule.meta.type).toBe('problem');
|
|
expect(rule.meta.docs.category).toBe('Architecture');
|
|
expect(rule.meta.docs.recommended).toBe(true);
|
|
expect(rule.meta.fixable).toBe(null);
|
|
expect(rule.meta.schema).toEqual([]);
|
|
expect(rule.meta.messages.frameworkImport).toBeDefined();
|
|
});
|
|
|
|
it('domain-no-application should have correct metadata', () => {
|
|
const rule = index.rules['domain-no-application'];
|
|
expect(rule.meta.type).toBe('problem');
|
|
expect(rule.meta.docs.category).toBe('Architecture');
|
|
expect(rule.meta.docs.recommended).toBe(true);
|
|
expect(rule.meta.fixable).toBe(null);
|
|
expect(rule.meta.schema).toEqual([]);
|
|
expect(rule.meta.messages.forbiddenImport).toBeDefined();
|
|
});
|
|
});
|
|
});
|