Skip to content

Commit

Permalink
Test escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Jul 10, 2020
1 parent 57551ee commit d3bc937
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/chartkick_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,41 @@ def test_chartkick_deep_merge_same_inner_key
end

def test_id
assert_match "id=\"test-123\"", line_chart(@data, id: "test-123")
assert_match "id=\"test-id\"", line_chart(@data, id: "test-id")
end

def test_id_escaped
assert_match "id=\"test-123"\"", line_chart(@data, id: "test-123\"")
end

def test_height
assert_match "height: 150px;", line_chart(@data, height: "150px")
end

def test_height_escaped
assert_match "height: 150px";", line_chart(@data, height: "150px\"")
end

def test_width
assert_match "width: 80%;", line_chart(@data, width: "80%")
end

def test_defer
assert_match "window.addEventListener", line_chart(@data, defer: true)
def test_width_escaped
assert_match "width: 80%";", line_chart(@data, width: "80%\"")
end

def test_nonce
assert_match "nonce=\"test-123\"", line_chart(@data, nonce: "test-123")
end

def test_nonce_escaped
assert_match "nonce=\"test-123"\"", line_chart(@data, nonce: "test-123\"")
end

def test_defer
assert_match "window.addEventListener", line_chart(@data, defer: true)
end

def test_content_for
refute_match "<script", line_chart(@data, content_for: :charts_js)
assert_match "<script", @content_for[:charts_js]
Expand Down

0 comments on commit d3bc937

Please sign in to comment.