@@ -88,21 +88,20 @@ describe('remarkCodeRegion — errors', () => {
8888 } ) ;
8989
9090 it ( 'throws on unclosed region' , ( ) => {
91- // Create inline content with an unclosed region
92- const input = '```python reference="snippets/example.py#nope"\n```' ;
93- // (The existing fixture doesn't have unclosed regions, so this just hits "not found")
94- expect ( ( ) => process ( input ) ) . toThrow ( ) ;
91+ const input = '```python reference="snippets/unclosed.py#oops"\n```' ;
92+ expect ( ( ) => process ( input ) ) . toThrow ( 'was opened but never closed' ) ;
9593 } ) ;
9694} ) ;
9795
9896describe ( 'remarkCodeRegion — auto-dedent' , ( ) => {
9997 it ( 'removes common leading whitespace from indented regions' , ( ) => {
100- const input = '```python reference="snippets/example .py#with_asserts "\n```' ;
98+ const input = '```python reference="snippets/indented .py#create_user "\n```' ;
10199 const output = process ( input ) ;
102- // The region content is inside a test function (no indent in this fixture,
103- // but verify dedent doesn't break non-indented code)
104- expect ( output ) . toContain ( 'result = 2 + 2' ) ;
105- expect ( output ) . not . toMatch ( / ^ r e s u l t / m) ;
100+ // The region is indented 8 spaces in the source (inside class + method).
101+ // After dedent, code should start at column 0.
102+ expect ( output ) . toContain ( 'from myapp import client' ) ;
103+ expect ( output ) . not . toMatch ( / ^ { 8 } f r o m m y a p p / m) ;
104+ expect ( output ) . toMatch ( / ^ f r o m m y a p p / m) ;
106105 } ) ;
107106} ) ;
108107
@@ -113,11 +112,13 @@ describe('remarkCodeRegion — security', () => {
113112 } ) ;
114113
115114 it ( 'allows outside references when allowOutsideRoot is true' , ( ) => {
116- // Reference a file we know exists outside fixtures but inside the project
117- const input = '```python reference="snippets/example.py#hello"\n```' ;
118- // This should work normally (within root)
115+ // Reference a file outside the fixtures root (go up two levels to project README)
116+ const input = '```markdown reference="../../README.md"\n```' ;
117+ // Without allowOutsideRoot, this would throw
118+ expect ( ( ) => process ( input ) ) . toThrow ( 'resolves outside the root directory' ) ;
119+ // With allowOutsideRoot, it should succeed
119120 const output = process ( input , { allowOutsideRoot : true } ) ;
120- expect ( output ) . toContain ( 'name = "World" ' ) ;
121+ expect ( output ) . toContain ( 'remark-code-region ' ) ;
121122 } ) ;
122123} ) ;
123124
0 commit comments