Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ describe("ActionViewTagHelperToHTMLRewriter", () => {

test("javascript_include_tag with defer", () => {
expect(transform(`<%= javascript_include_tag "application", defer: true %>`)).toBe(
`<script defer src="<%= javascript_path("application") %>"></script>`
`<script src="<%= javascript_path("application") %>" defer></script>`
)
})

Expand All @@ -670,7 +670,7 @@ describe("ActionViewTagHelperToHTMLRewriter", () => {

test("javascript_include_tag with nonce true resolves to content_security_policy_nonce", () => {
expect(transform(`<%= javascript_include_tag "application", nonce: true %>`)).toBe(
`<script nonce="<%= content_security_policy_nonce %>" src="<%= javascript_path("application") %>"></script>`
`<script src="<%= javascript_path("application") %>" nonce="<%= content_security_policy_nonce %>"></script>`
)
})

Expand All @@ -682,13 +682,13 @@ describe("ActionViewTagHelperToHTMLRewriter", () => {

test("javascript_include_tag with interpolated nonce", () => {
expect(transform('<%= javascript_include_tag "application", nonce: "static-#{dynamic}" %>')).toBe(
'<script nonce="static-<%= dynamic %>" src="<%= javascript_path("application") %>"></script>'
'<script src="<%= javascript_path("application") %>" nonce="static-<%= dynamic %>"></script>'
)
})

test("javascript_include_tag with data attributes", () => {
expect(transform(`<%= javascript_include_tag "application", data: { turbo_track: "reload" } %>`)).toBe(
`<script data-turbo-track="reload" src="<%= javascript_path("application") %>"></script>`
`<script src="<%= javascript_path("application") %>" data-turbo-track="reload"></script>`
)
})

Expand Down Expand Up @@ -718,25 +718,25 @@ describe("ActionViewTagHelperToHTMLRewriter", () => {

test("javascript_include_tag with URL and nonce", () => {
expect(transform(`<%= javascript_include_tag "http://www.example.com/xmlhr.js", nonce: true %>`)).toBe(
`<script nonce="<%= content_security_policy_nonce %>" src="http://www.example.com/xmlhr.js"></script>`
`<script src="http://www.example.com/xmlhr.js" nonce="<%= content_security_policy_nonce %>"></script>`
)
})

test("javascript_include_tag with URL and async", () => {
expect(transform(`<%= javascript_include_tag "http://www.example.com/xmlhr.js", async: true %>`)).toBe(
`<script async src="http://www.example.com/xmlhr.js"></script>`
`<script src="http://www.example.com/xmlhr.js" async></script>`
)
})

test("javascript_include_tag with URL and defer", () => {
expect(transform(`<%= javascript_include_tag "http://www.example.com/xmlhr.js", defer: true %>`)).toBe(
`<script defer src="http://www.example.com/xmlhr.js"></script>`
`<script src="http://www.example.com/xmlhr.js" defer></script>`
)
})

test("javascript_include_tag with defer as string", () => {
expect(transform(`<%= javascript_include_tag "application", defer: "true" %>`)).toBe(
`<script defer="true" src="<%= javascript_path("application") %>"></script>`
`<script src="<%= javascript_path("application") %>" defer="true"></script>`
)
})

Expand Down
Loading
Loading