test/helper_test.rb in vite_rails-1.0.11 vs test/helper_test.rb in vite_rails-1.0.12

- old
+ new

@@ -25,37 +25,36 @@ assert_equal '<script src="/vite-production/@vite/client" type="module"></script>', vite_client_tag } end def test_vite_asset_path - assert_equal '/vite-production/assets/colored.1173bfe0.js', vite_asset_path('colored.js') - assert_equal '/vite-production/assets/colored.84277fd6.css', vite_asset_path('colored.css') + assert_equal '/vite-production/assets/application.d9514acc.js', vite_asset_path('application.ts') + assert_equal '/vite-production/assets/styles.0e53e684.css', vite_asset_path('styles.css') with_dev_server_running { - assert_equal '/vite-production/colored.js', vite_asset_path('colored.js') - assert_equal '/vite-production/colored.css', vite_asset_path('colored.css') + assert_equal '/vite-production/application.ts', vite_asset_path('application.ts') + assert_equal '/vite-production/styles.css', vite_asset_path('styles.css') } end def test_vite_stylesheet_tag - assert_equal %(<link rel="stylesheet" media="screen" href="/vite-production/assets/colored.84277fd6.css" />), - vite_stylesheet_tag('colored') + assert_equal link(href: '/vite-production/assets/styles.0e53e684.css'), vite_stylesheet_tag('styles') - assert_equal vite_stylesheet_tag('colored'), vite_stylesheet_tag('colored.css') + assert_equal vite_stylesheet_tag('styles'), vite_stylesheet_tag('styles.css') with_dev_server_running { - assert_equal %(<link rel="stylesheet" media="screen" href="/vite-production/colored.css" />), - vite_stylesheet_tag('colored') + assert_equal link(href: '/vite-production/styles.css'), vite_stylesheet_tag('styles') - assert_equal vite_stylesheet_tag('colored'), vite_stylesheet_tag('colored.css') + assert_equal vite_stylesheet_tag('styles'), vite_stylesheet_tag('styles.css') } end def test_vite_javascript_tag assert_equal [ - %(<script src="/vite-production/assets/application.a0ba047e.js" crossorigin="anonymous" type="module"></script>), + %(<script src="/vite-production/assets/application.d9514acc.js" crossorigin="anonymous" type="module"></script>), + %(<link rel="preload" href="/vite-production/assets/vendor.880705da.js" as="script" type="text/javascript" crossorigin="anonymous">), %(<link rel="preload" href="/vite-production/assets/example_import.8e1fddc0.js" as="script" type="text/javascript" crossorigin="anonymous">), - %(<link rel="stylesheet" media="screen" href="/vite-production/assets/application.cccfef34.css" />), + link(href: '/vite-production/assets/application.f510c1e9.css'), ].join, vite_javascript_tag('application') assert_equal vite_javascript_tag('application'), vite_javascript_tag('application.js') assert_equal vite_javascript_tag('application'), vite_typescript_tag('application') @@ -64,7 +63,13 @@ vite_javascript_tag('application') assert_equal %(<script src="/vite-production/application.ts" crossorigin="anonymous" type="module"></script>), vite_typescript_tag('application') } + end + + def link(href:, rel: 'stylesheet', media: 'screen') + attrs = [%(media="#{ media }"), %(href="#{ href }")] + attrs.reverse! if Rails.gem_version > Gem::Version.new('6.1.1') + %(<link rel="#{ rel }" #{ attrs.join(' ') } />) end end