@@ -2,6 +2,7 @@ const { test, snapshot } = require("node:test");
2
2
const { transformSync } = require ( "../dist/index.js" ) ;
3
3
const path = require ( "node:path" ) ;
4
4
const assert = require ( "node:assert" ) ;
5
+ const vm = require ( "node:vm" ) ;
5
6
6
7
// Set the path for the snapshots directory
7
8
snapshot . setResolveSnapshotPath ( ( testPath ) => {
@@ -146,3 +147,32 @@ test("should not polyfill using Symbol.asyncDispose", (t) => {
146
147
const { code } = transformSync ( inputCode ) ;
147
148
assert . strictEqual ( code , inputCode ) ;
148
149
} ) ;
150
+
151
+ test ( "should not break on return new line when stripped" , ( t ) => {
152
+ const inputCode = `
153
+ function mkId() {
154
+ return <T>
155
+ (x: T)=>x;
156
+ }
157
+ const id = mkId();
158
+ output = id(5);` ;
159
+ const { code } = transformSync ( inputCode ) ;
160
+ t . assert . snapshot ( code ) ;
161
+ const result = vm . runInContext ( code , vm . createContext ( ) ) ;
162
+ assert . strictEqual ( result , 5 ) ;
163
+ } ) ;
164
+
165
+ test ( "should not break on return new line when stripped (alternative formatting)" , ( t ) => {
166
+ const inputCode = `
167
+ function mkId() {
168
+ return <
169
+ T
170
+ >(x: T)=>x;
171
+ }
172
+ const id = mkId();
173
+ output = id(7);` ;
174
+ const { code } = transformSync ( inputCode ) ;
175
+ t . assert . snapshot ( code ) ;
176
+ const result = vm . runInContext ( code , vm . createContext ( ) ) ;
177
+ assert . strictEqual ( result , 7 ) ;
178
+ } ) ;
0 commit comments