@@ -9,51 +9,9 @@ describe('ContextLinter', () => {
9
9
beforeAll ( ( ) => {
10
10
// Create test directory and files
11
11
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 ` ) ;
50
14
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' ) ;
57
15
} ) ;
58
16
59
17
afterAll ( ( ) => {
@@ -71,14 +29,19 @@ This is a test module.
71
29
expect ( result ) . toBe ( true ) ;
72
30
} ) ;
73
31
74
- it ( 'should respect .contextignore rules' , async ( ) => {
32
+ it ( 'should respect .contextignore rules and process .context files ' , async ( ) => {
75
33
const consoleSpy = jest . spyOn ( console , 'log' ) ;
76
- await linter . lintDirectory ( testDir , '1.0.0' ) ;
34
+ const result = await linter . lintDirectory ( testDir , '1.0.0' ) ;
77
35
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.' ) ;
82
45
83
46
consoleSpy . mockRestore ( ) ;
84
47
} ) ;
@@ -90,7 +53,8 @@ This is a test module.
90
53
await linter . lintDirectory ( testDir , '1.0.0' ) ;
91
54
92
55
// 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 ( / M a i n c o n t e x t : .* 1 0 0 \. 0 0 % / ) ) ;
94
58
95
59
consoleSpy . mockRestore ( ) ;
96
60
} ) ;
0 commit comments