@@ -116,6 +116,42 @@ class Propshaft::ManifestTest < ActiveSupport::TestCase
116
116
assert_nil entry . integrity
117
117
end
118
118
119
+ test "transform_values applies block to all entries" do
120
+ manifest = Propshaft ::Manifest . new
121
+
122
+ entry1 = Propshaft ::Manifest ::ManifestEntry . new (
123
+ logical_path : "app.js" ,
124
+ digested_path : "app-abc123.js" ,
125
+ integrity : "sha384-test1"
126
+ )
127
+
128
+ entry2 = Propshaft ::Manifest ::ManifestEntry . new (
129
+ logical_path : "style.css" ,
130
+ digested_path : "style-def456.css" ,
131
+ integrity : nil
132
+ )
133
+
134
+ manifest . push ( entry1 )
135
+ manifest . push ( entry2 )
136
+
137
+ # Transform to get digested_path
138
+ hash = manifest . transform_values { |entry | entry . digested_path }
139
+ assert_equal ( { "app.js" => "app-abc123.js" , "style.css" => "style-def456.css" } , hash )
140
+
141
+ # Transform to get integrity
142
+ hash = manifest . transform_values { |entry | entry . integrity }
143
+ assert_equal ( { "app.js" => "sha384-test1" , "style.css" => nil } , hash )
144
+
145
+ # Transform to get logical_path (for demonstration)
146
+ hash = manifest . transform_values { |entry | entry . logical_path }
147
+ assert_equal ( { "app.js" => "app.js" , "style.css" => "style.css" } , hash )
148
+ end
149
+
150
+ test "transform_values returns empty hash for empty manifest" do
151
+ manifest = Propshaft ::Manifest . new
152
+ assert_equal ( { } , manifest . transform_values { |entry | entry . digested_path } )
153
+ end
154
+
119
155
private
120
156
def create_manifest ( integrity_hash_algorithm = nil )
121
157
Propshaft ::Manifest . new ( integrity_hash_algorithm :) . tap do |manifest |
0 commit comments