Skip to content

Commit

Permalink
✅ fixes unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
josemigallas committed Sep 4, 2024
1 parent 76c29cb commit e7874fb
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions test/unit/liquid/filters/rails_helpers_test.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'test_helper'

class Liquid::Filters::RailsHelpersTest < ActiveSupport::TestCase
Expand All @@ -10,8 +12,34 @@ def setup

test 'javascript_include_tag' do
@context.registers[:controller] = ApplicationController.new
WebpackHelper.expects(:javascript_packs_with_chunks_tag).returns('/packs/stats.js') # TODO: FIXME!!!
assert_equal "<script src=\"/packs/stats.js\"></script>", javascript_include_tag('stats.js')

test_manifest ||= {
entrypoints: {
stats: {
assets: {
js: ['/packs/stats.js'],
css: ['/packs/stats.css']
}
},
'validate_signup.ts': {
assets: {
js: ['/packs/foo.js']
}
}
}
}.to_json

# FIXME: we should mock javascript_packs_with_chunks_tag or load_webpack_manifest instead of File
File.stubs(:read).with('public/packs/manifest.json').returns(test_manifest).once

assert_same_elements [
"<script src=\"/packs/stats.js\"></script>",
"<link rel=\"stylesheet\" media=\"screen\" href=\"/packs/stats.css\" />"
], javascript_include_tag('stats.js').split(/\n/)

assert_same_elements [
"<script src=\"/packs/foo.js\"></script>"
], javascript_include_tag('validate_signup.js').split(/\n/)
end

test 'mail_to' do
Expand Down

0 comments on commit e7874fb

Please sign in to comment.