Skip to content

Commit 8c07847

Browse files
committed
fix: change output and fix tests
1 parent 7f06d06 commit 8c07847

File tree

3 files changed

+17
-53
lines changed

3 files changed

+17
-53
lines changed

linters/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build": "tsc",
1111
"start": "node dist/cli.js",
1212
"lint": "node dist/cli.js",
13-
"test": "jest",
13+
"test": "tsc && jest",
1414
"prepublishOnly": "npm run build",
1515
"semantic-release": "semantic-release",
1616
"check-updates": "npm outdated"

linters/typescript/src/__tests__/context_linter.test.ts

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,9 @@ describe('ContextLinter', () => {
99
beforeAll(() => {
1010
// Create test directory and files
1111
fs.mkdirSync(testDir, { recursive: true });
12-
fs.writeFileSync(path.join(testDir, '.contextignore'), `
13-
ignored.md
14-
`);
15-
fs.writeFileSync(path.join(testDir, '.context.md'), `---
16-
module-name: test-module
17-
related-modules: []
18-
version: 1.0.0
19-
description: A test module
20-
diagrams: []
21-
technologies: ['TypeScript', 'Jest']
22-
conventions: ['Use camelCase for variables']
23-
directives: []
24-
architecture:
25-
style: 'Modular'
26-
components: ['Component A', 'Component B']
27-
data-flow: ['Component A -> Component B']
28-
development:
29-
setup-steps: ['Install dependencies', 'Configure environment']
30-
build-command: 'npm run build'
31-
test-command: 'npm test'
32-
business-requirements:
33-
key-features: ['Feature 1', 'Feature 2']
34-
target-audience: 'Developers'
35-
success-metrics: ['Code coverage', 'Performance']
36-
quality-assurance:
37-
testing-frameworks: ['Jest']
38-
coverage-threshold: '80%'
39-
performance-benchmarks: ['Load time < 1s']
40-
deployment:
41-
platform: 'AWS'
42-
cicd-pipeline: 'GitHub Actions'
43-
staging-environment: 'staging.example.com'
44-
production-environment: 'production.example.com'
45-
---
46-
# Test Module
47-
48-
This is a test module.
49-
`);
12+
fs.writeFileSync(path.join(testDir, '.contextignore'), `\n ignored.md\n `);
13+
fs.writeFileSync(path.join(testDir, '.context.md'), `---\nmodule-name: test-module\nrelated-modules: []\nversion: 1.0.0\ndescription: A test module\ndiagrams: []\ntechnologies: ['TypeScript', 'Jest']\nconventions: ['Use camelCase for variables']\ndirectives: []\narchitecture:\n style: 'Modular'\n components: ['Component A', 'Component B']\n data-flow: ['Component A -> Component B']\ndevelopment:\n setup-steps: ['Install dependencies', 'Configure environment']\n build-command: 'npm run build'\n test-command: 'npm test'\nbusiness-requirements:\n key-features: ['Feature 1', 'Feature 2']\n target-audience: 'Developers'\n success-metrics: ['Code coverage', 'Performance']\nquality-assurance:\n testing-frameworks: ['Jest']\n coverage-threshold: '80%'\n performance-benchmarks: ['Load time < 1s']\ndeployment:\n platform: 'AWS'\n cicd-pipeline: 'GitHub Actions'\n staging-environment: 'staging.example.com'\n production-environment: 'production.example.com'\n---\n# Test Module\n\nThis is a test module.\n `);
5014
fs.writeFileSync(path.join(testDir, 'ignored.md'), 'This file should be ignored');
51-
fs.writeFileSync(path.join(testDir, 'not_ignored.md'), 'This file should not be ignored');
52-
53-
// Create a subdirectory with its own .contextignore
54-
const subDir = path.join(testDir, 'subdir');
55-
fs.mkdirSync(subDir, { recursive: true });
56-
fs.writeFileSync(path.join(subDir, '.contextignore'), '# Subdir ignore rules');
5715
});
5816

5917
afterAll(() => {
@@ -71,14 +29,19 @@ This is a test module.
7129
expect(result).toBe(true);
7230
});
7331

74-
it('should respect .contextignore rules', async () => {
32+
it('should respect .contextignore rules and process .context files', async () => {
7533
const consoleSpy = jest.spyOn(console, 'log');
76-
await linter.lintDirectory(testDir, '1.0.0');
34+
const result = await linter.lintDirectory(testDir, '1.0.0');
7735

78-
// Check if ignored.md was listed in ignored files
79-
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('ignored.md'));
80-
// Check if not_ignored.md was not listed in ignored files
81-
expect(consoleSpy).not.toHaveBeenCalledWith(expect.stringContaining('not_ignored.md'));
36+
// Check that the ignored file is not processed
37+
expect(consoleSpy).not.toHaveBeenCalledWith(expect.stringContaining('ignored.md'));
38+
39+
// Check that the .context.md file is processed
40+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('.context.md'));
41+
42+
// Check that the linting process completed successfully
43+
expect(result).toBe(true);
44+
expect(consoleSpy).toHaveBeenCalledWith('Linting completed.');
8245

8346
consoleSpy.mockRestore();
8447
});
@@ -90,7 +53,8 @@ This is a test module.
9053
await linter.lintDirectory(testDir, '1.0.0');
9154

9255
// Check if the main context was processed (which should be the .context.md file)
93-
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('main context: 100.00%'));
56+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Main context:'));
57+
expect(consoleSpy).toHaveBeenCalledWith(expect.stringMatching(/Main context:.*100\.00%/));
9458

9559
consoleSpy.mockRestore();
9660
});

linters/typescript/src/__tests__/contextignore_linter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe('ContextignoreLinter', () => {
100100

101101
expect(normalizedIgnoredFiles).toEqual(expect.arrayContaining([
102102
path.join(testDir, 'test.log'),
103-
path.join(testDir, 'build', 'main.js')
103+
path.join(testDir, 'build')
104104
]));
105105
expect(normalizedIgnoredFiles).not.toContain(path.join(testDir, 'src.js'));
106106
});

0 commit comments

Comments
 (0)