@@ -184,6 +184,7 @@ def test_security_log_event_union_type
184184 # Verify we extracted the correct enum values - sort both arrays to avoid order issues
185185 expected_values = [ "IPSpoof" , "CSRFViolation" , "BlockedHost" ] . sort
186186 extracted_values = type_info [ :enum_values ] . sort
187+
187188 assert_equal expected_values , extracted_values , "Should extract the correct enum values"
188189
189190 # Test the resulting TypeScript type
@@ -203,9 +204,11 @@ def test_security_log_event_union_type
203204 # Check that the SecurityLog interface has the event field with a union type
204205 # We don't check the exact string since the order may vary
205206 security_log_section = content . match ( /export interface SecurityLog \{ .*?\} /m )
207+
206208 assert security_log_section , "Should find SecurityLog interface in the generated TypeScript"
207209
208210 event_line = security_log_section [ 0 ] . lines . find { |line | line . strip . start_with? ( "event:" ) }
211+
209212 assert event_line , "SecurityLog interface should have an event field"
210213
211214 # Verify that the event line contains all three enum values and union operators
@@ -229,61 +232,72 @@ def test_single_enum_value_restriction
229232
230233 # Test the resulting TypeScript type
231234 ts_type = @exporter . typescript_type_for ( type_info )
235+
232236 assert_equal "Source.JOB" , ts_type , "TypeScript type should be the specific enum value"
233237
234238 # Now check that the full TypeScript generation includes this restricted type
235239 content = @exporter . generate_typescript_definitions
236240
237241 # Find the ActiveJobLog interface section
238242 job_log_section = content . match ( /export interface ActiveJobLog \{ .*?\} /m )
243+
239244 assert job_log_section , "Should find ActiveJobLog interface in the generated TypeScript"
240245
241246 # Extract the source line and check if it has the specific enum value
242247 source_line = job_log_section [ 0 ] . lines . find { |line | line . strip . start_with? ( "source:" ) }
248+
243249 assert source_line , "ActiveJobLog interface should have a source field"
244250
245251 # The source field should be a specific enum value, not a generic Source enum
246- assert_equal "source: Source.JOB;" , source_line . strip ,
252+ assert_equal "source: Source.JOB;" ,
253+ source_line . strip ,
247254 "source field should be Source.JOB specifically, not just Source"
248255 refute_includes source_line , "Source;" , "source field should not be the general Source enum"
249256 end
250-
257+
251258 def test_exports_log_event_type_arrays
252259 # Test that we export valid event type arrays for each log type
253260 content = @exporter . generate_typescript_definitions
254-
261+
255262 # Check Security log events array
256263 security_array_match = content . match ( /export const SecurityLogEvents: Array<(.*?)> = \[ (.*?)\] /m )
264+
257265 assert security_array_match , "Should export a SecurityLogEvents array"
258-
266+
259267 # Check the union type for the array
260268 security_type = security_array_match [ 1 ]
269+
261270 [ "LogEvent.BLOCKED_HOST" , "LogEvent.CSRF_VIOLATION" , "LogEvent.IP_SPOOF" ] . each do |event |
262271 assert_includes security_type , event , "SecurityLogEvents type should contain #{ event } "
263272 end
264-
273+
265274 # Check the array content
266275 security_array_content = security_array_match [ 2 ]
276+
267277 [ "LogEvent.BLOCKED_HOST" , "LogEvent.CSRF_VIOLATION" , "LogEvent.IP_SPOOF" ] . each do |event |
268278 assert_includes security_array_content , event , "SecurityLogEvents array should contain #{ event } "
269279 end
270-
280+
271281 # Check ActiveJob log events array
272282 activejob_array_match = content . match ( /export const ActiveJobLogEvents: Array<(.*?)> = \[ (.*?)\] /m )
283+
273284 assert activejob_array_match , "Should export an ActiveJobLogEvents array"
274-
285+
275286 # Check the array content
276287 activejob_array_content = activejob_array_match [ 2 ]
288+
277289 [ "LogEvent.ENQUEUE" , "LogEvent.START" , "LogEvent.FINISH" , "LogEvent.SCHEDULE" ] . each do |event |
278290 assert_includes activejob_array_content , event , "ActiveJobLogEvents array should contain #{ event } "
279291 end
280-
292+
281293 # Check ActiveStorage log events array
282294 storage_array_match = content . match ( /export const ActiveStorageLogEvents: Array<(.*?)> = \[ (.*?)\] /m )
295+
283296 assert storage_array_match , "Should export an ActiveStorageLogEvents array"
284-
297+
285298 # Check the array content
286299 storage_array_content = storage_array_match [ 2 ]
300+
287301 [ "LogEvent.UPLOAD" , "LogEvent.DOWNLOAD" , "LogEvent.DELETE" , "LogEvent.STREAM" ] . each do |event |
288302 assert_includes storage_array_content , event , "ActiveStorageLogEvents array should contain #{ event } "
289303 end
0 commit comments