22 * Plugin Analyzer Tests
33 */
44
5- const { describe, it, beforeEach, afterEach } = require ( 'node:test' ) ;
6- const assert = require ( 'node:assert' ) ;
75const fs = require ( 'fs' ) ;
86const path = require ( 'path' ) ;
97
@@ -27,8 +25,8 @@ describe('Plugin Patterns', () => {
2725 const pattern = pluginPatterns . pluginPatterns . missing_additional_properties ;
2826 const result = pattern . check ( schema ) ;
2927
30- assert . ok ( result , 'Should detect missing additionalProperties' ) ;
31- assert . ok ( result . issue . includes ( 'additionalProperties' ) ) ;
28+ expect ( result ) . toBeTruthy ( ) ;
29+ expect ( result . issue ) . toContain ( 'additionalProperties' ) ;
3230 } ) ;
3331
3432 it ( 'should not flag when additionalProperties is false' , ( ) => {
@@ -43,7 +41,7 @@ describe('Plugin Patterns', () => {
4341 const pattern = pluginPatterns . pluginPatterns . missing_additional_properties ;
4442 const result = pattern . check ( schema ) ;
4543
46- assert . strictEqual ( result , null , 'Should not flag when additionalProperties is false' ) ;
44+ expect ( result ) . toBeNull ( ) ;
4745 } ) ;
4846
4947 it ( 'should provide auto-fix function' , ( ) => {
@@ -57,10 +55,10 @@ describe('Plugin Patterns', () => {
5755 const pattern = pluginPatterns . pluginPatterns . missing_additional_properties ;
5856 const result = pattern . check ( schema ) ;
5957
60- assert . ok ( result . autoFixFn , 'Should have auto-fix function' ) ;
58+ expect ( result . autoFixFn ) . toBeTruthy ( ) ;
6159
6260 const fixed = result . autoFixFn ( schema ) ;
63- assert . strictEqual ( fixed . additionalProperties , false ) ;
61+ expect ( fixed . additionalProperties ) . toBe ( false ) ;
6462 } ) ;
6563 } ) ;
6664
@@ -77,7 +75,7 @@ describe('Plugin Patterns', () => {
7775 const pattern = pluginPatterns . pluginPatterns . missing_required_fields ;
7876 const result = pattern . check ( schema ) ;
7977
80- assert . ok ( result , 'Should detect missing required array' ) ;
78+ expect ( result ) . toBeTruthy ( ) ;
8179 } ) ;
8280
8381 it ( 'should not flag when required is present' , ( ) => {
@@ -92,7 +90,7 @@ describe('Plugin Patterns', () => {
9290 const pattern = pluginPatterns . pluginPatterns . missing_required_fields ;
9391 const result = pattern . check ( schema ) ;
9492
95- assert . strictEqual ( result , null ) ;
93+ expect ( result ) . toBeNull ( ) ;
9694 } ) ;
9795 } ) ;
9896
@@ -104,9 +102,9 @@ describe('Plugin Patterns', () => {
104102 const pattern = pluginPatterns . pluginPatterns . version_mismatch ;
105103 const result = pattern . check ( pluginJson , packageJson ) ;
106104
107- assert . ok ( result , 'Should detect version mismatch' ) ;
108- assert . ok ( result . issue . includes ( '1.0.0' ) ) ;
109- assert . ok ( result . issue . includes ( '2.0.0' ) ) ;
105+ expect ( result ) . toBeTruthy ( ) ;
106+ expect ( result . issue ) . toContain ( '1.0.0' ) ;
107+ expect ( result . issue ) . toContain ( '2.0.0' ) ;
110108 } ) ;
111109
112110 it ( 'should not flag when versions match' , ( ) => {
@@ -116,7 +114,7 @@ describe('Plugin Patterns', () => {
116114 const pattern = pluginPatterns . pluginPatterns . version_mismatch ;
117115 const result = pattern . check ( pluginJson , packageJson ) ;
118116
119- assert . strictEqual ( result , null ) ;
117+ expect ( result ) . toBeNull ( ) ;
120118 } ) ;
121119 } ) ;
122120
@@ -147,8 +145,8 @@ describe('Plugin Patterns', () => {
147145 const pattern = pluginPatterns . pluginPatterns . deep_nesting ;
148146 const result = pattern . check ( schema ) ;
149147
150- assert . ok ( result , 'Should detect deep nesting' ) ;
151- assert . ok ( result . issue . includes ( 'nested' ) ) ;
148+ expect ( result ) . toBeTruthy ( ) ;
149+ expect ( result . issue ) . toContain ( 'nested' ) ;
152150 } ) ;
153151 } ) ;
154152} ) ;
@@ -161,7 +159,7 @@ describe('Tool Patterns', () => {
161159 const pattern = toolPatterns . toolPatterns . poor_tool_naming ;
162160 const result = pattern . check ( tool ) ;
163161
164- assert . ok ( result , 'Should flag non-verb name' ) ;
162+ expect ( result ) . toBeTruthy ( ) ;
165163 } ) ;
166164
167165 it ( 'should accept verb-prefixed names' , ( ) => {
@@ -170,7 +168,7 @@ describe('Tool Patterns', () => {
170168 const pattern = toolPatterns . toolPatterns . poor_tool_naming ;
171169 const result = pattern . check ( tool ) ;
172170
173- assert . strictEqual ( result , null ) ;
171+ expect ( result ) . toBeNull ( ) ;
174172 } ) ;
175173 } ) ;
176174
@@ -189,7 +187,7 @@ describe('Tool Patterns', () => {
189187
190188 const issues = toolPatterns . analyzeTool ( tool ) ;
191189
192- assert . ok ( issues . length > 0 , 'Should find issues' ) ;
190+ expect ( issues . length ) . toBeGreaterThan ( 0 ) ;
193191 } ) ;
194192 } ) ;
195193} ) ;
@@ -208,7 +206,7 @@ tools: Read, Bash, Grep
208206 const issues = securityPatterns . checkSecurity ( content , 'test.md' ) ;
209207
210208 const bashIssue = issues . find ( i => i . patternId === 'unrestricted_bash' ) ;
211- assert . ok ( bashIssue , 'Should detect unrestricted Bash' ) ;
209+ expect ( bashIssue ) . toBeTruthy ( ) ;
212210 } ) ;
213211
214212 it ( 'should not flag restricted Bash' , ( ) => {
@@ -223,7 +221,7 @@ tools: Read, Bash(git:*), Grep
223221 const issues = securityPatterns . checkSecurity ( content , 'test.md' ) ;
224222
225223 const bashIssue = issues . find ( i => i . patternId === 'unrestricted_bash' ) ;
226- assert . strictEqual ( bashIssue , undefined , 'Should not flag restricted Bash' ) ;
224+ expect ( bashIssue ) . toBeUndefined ( ) ;
227225 } ) ;
228226 } ) ;
229227
@@ -238,7 +236,7 @@ const config = {
238236 const issues = securityPatterns . checkSecurity ( content , 'config.js' ) ;
239237
240238 const secretIssue = issues . find ( i => i . patternId === 'hardcoded_secrets' ) ;
241- assert . ok ( secretIssue , 'Should detect hardcoded secret' ) ;
239+ expect ( secretIssue ) . toBeTruthy ( ) ;
242240 } ) ;
243241 } ) ;
244242} ) ;
@@ -258,9 +256,9 @@ describe('Reporter', () => {
258256
259257 const report = reporter . generateReport ( results ) ;
260258
261- assert . ok ( report . includes ( 'test-plugin' ) ) ;
262- assert . ok ( report . includes ( 'get_data' ) ) ;
263- assert . ok ( report . includes ( 'HIGH' ) ) ;
259+ expect ( report ) . toContain ( 'test-plugin' ) ;
260+ expect ( report ) . toContain ( 'get_data' ) ;
261+ expect ( report ) . toContain ( 'HIGH' ) ;
264262 } ) ;
265263
266264 it ( 'should filter LOW certainty when not verbose' , ( ) => {
@@ -277,8 +275,8 @@ describe('Reporter', () => {
277275
278276 const report = reporter . generateReport ( results , { verbose : false } ) ;
279277
280- assert . ok ( ! report . includes ( 'Low issue' ) , 'Should not include LOW issues ') ;
281- assert . ok ( report . includes ( 'High issue' ) , 'Should include HIGH issues ') ;
278+ expect ( report ) . not . toContain ( 'Low issue' ) ;
279+ expect ( report ) . toContain ( 'High issue' ) ;
282280 } ) ;
283281 } ) ;
284282} ) ;
@@ -295,7 +293,7 @@ describe('Fixer', () => {
295293
296294 const fixed = fixer . fixAdditionalProperties ( schema ) ;
297295
298- assert . strictEqual ( fixed . additionalProperties , false ) ;
296+ expect ( fixed . additionalProperties ) . toBe ( false ) ;
299297 } ) ;
300298
301299 it ( 'should recursively fix nested schemas' , ( ) => {
@@ -313,8 +311,8 @@ describe('Fixer', () => {
313311
314312 const fixed = fixer . fixAdditionalProperties ( schema ) ;
315313
316- assert . strictEqual ( fixed . additionalProperties , false ) ;
317- assert . strictEqual ( fixed . properties . nested . additionalProperties , false ) ;
314+ expect ( fixed . additionalProperties ) . toBe ( false ) ;
315+ expect ( fixed . properties . nested . additionalProperties ) . toBe ( false ) ;
318316 } ) ;
319317 } ) ;
320318
@@ -330,9 +328,9 @@ describe('Fixer', () => {
330328
331329 const fixed = fixer . fixRequiredFields ( schema ) ;
332330
333- assert . ok ( fixed . required ) ;
334- assert . ok ( fixed . required . includes ( 'name' ) ) ;
335- assert . ok ( fixed . required . includes ( 'age' ) ) ;
331+ expect ( fixed . required ) . toBeTruthy ( ) ;
332+ expect ( fixed . required ) . toContain ( 'name' ) ;
333+ expect ( fixed . required ) . toContain ( 'age' ) ;
336334 } ) ;
337335
338336 it ( 'should exclude optional fields' , ( ) => {
@@ -346,8 +344,8 @@ describe('Fixer', () => {
346344
347345 const fixed = fixer . fixRequiredFields ( schema ) ;
348346
349- assert . ok ( fixed . required . includes ( 'name' ) ) ;
350- assert . ok ( ! fixed . required . includes ( 'nickname' ) , 'Should not include optional field ') ;
347+ expect ( fixed . required ) . toContain ( 'name' ) ;
348+ expect ( fixed . required ) . not . toContain ( 'nickname' ) ;
351349 } ) ;
352350 } ) ;
353351
@@ -360,8 +358,8 @@ describe('Fixer', () => {
360358
361359 const previews = fixer . previewFixes ( issues ) ;
362360
363- assert . strictEqual ( previews [ 0 ] . willApply , true ) ;
364- assert . strictEqual ( previews [ 1 ] . willApply , false ) ;
361+ expect ( previews [ 0 ] . willApply ) . toBe ( true ) ;
362+ expect ( previews [ 1 ] . willApply ) . toBe ( false ) ;
365363 } ) ;
366364 } ) ;
367365} ) ;
0 commit comments