@@ -239,6 +239,65 @@ function old_function() {}`;
239239 } ) ;
240240 } ) ;
241241
242+ describe ( 'Block.json file patterns (src/**/block.json)' , ( ) => {
243+ const patterns = [
244+ {
245+ search : / " v e r s i o n " : " \d + \. \d + \. \d + " / ,
246+ replace : `"version": "${ testVersion } "` ,
247+ } ,
248+ ] ;
249+
250+ test ( 'replaces version field in block.json' , ( ) => {
251+ const content = `{
252+ "$schema": "https://schemas.wp.org/trunk/block.json",
253+ "name": "activitypub/follow-me",
254+ "version": "2.0.0",
255+ "title": "Follow me"
256+ }` ;
257+
258+ const result = applyVersionReplacements ( content , testVersion , patterns ) ;
259+ expect ( result ) . toContain ( `"version": "${ testVersion } "` ) ;
260+ expect ( result ) . not . toContain ( '"version": "2.0.0"' ) ;
261+ } ) ;
262+
263+ test ( 'replaces version in block.json fixture file' , ( ) => {
264+ const fixturePath = path . join ( __dirname , 'fixtures' , 'block.json' ) ;
265+ const content = fs . readFileSync ( fixturePath , 'utf8' ) ;
266+
267+ const result = applyVersionReplacements ( content , testVersion , patterns ) ;
268+ expect ( result ) . toContain ( `"version": "${ testVersion } "` ) ;
269+ expect ( result ) . not . toContain ( '"version": "2.0.0"' ) ;
270+ } ) ;
271+
272+ test ( 'preserves other JSON structure' , ( ) => {
273+ const content = `{
274+ "$schema": "https://schemas.wp.org/trunk/block.json",
275+ "name": "activitypub/test-block",
276+ "apiVersion": 3,
277+ "version": "1.5.0",
278+ "title": "Test Block",
279+ "category": "widgets"
280+ }` ;
281+
282+ const result = applyVersionReplacements ( content , testVersion , patterns ) ;
283+ expect ( result ) . toContain ( '"name": "activitypub/test-block"' ) ;
284+ expect ( result ) . toContain ( '"apiVersion": 3' ) ;
285+ expect ( result ) . toContain ( '"title": "Test Block"' ) ;
286+ expect ( result ) . toContain ( `"version": "${ testVersion } "` ) ;
287+ } ) ;
288+
289+ test ( 'handles version field regardless of position' , ( ) => {
290+ const content = `{
291+ "version": "0.9.0",
292+ "name": "activitypub/early-version"
293+ }` ;
294+
295+ const result = applyVersionReplacements ( content , testVersion , patterns ) ;
296+ expect ( result ) . toContain ( `"version": "${ testVersion } "` ) ;
297+ expect ( result ) . not . toContain ( '"version": "0.9.0"' ) ;
298+ } ) ;
299+ } ) ;
300+
242301 describe ( 'Edge cases and complex scenarios' , ( ) => {
243302 test ( 'handles multiple replacements in single file' , ( ) => {
244303 const content = `/**
0 commit comments