mirror of
https://github.com/rails/jquery-rails.git
synced 2026-01-09 14:47:55 -05:00
Merge pull request #243 from juank-pa/support_even_more_css_selectors
Support even more CSS selectors
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
- Add possibility to test HTML: all, attribute prefix, attribute contains,
|
||||
attribute ends with, child, and class selectors
|
||||
- Fix matching mutiple calls for the same selector/function exception
|
||||
|
||||
## 4.3.1
|
||||
|
||||
@@ -134,6 +134,15 @@ module Rails::Dom::Testing::Assertions::SelectorAssertions
|
||||
|
||||
id = selector.gsub('[', '\[')
|
||||
id.gsub!(']', '\]')
|
||||
id.gsub!('*', '\*')
|
||||
id.gsub!('(', '\(')
|
||||
id.gsub!(')', '\)')
|
||||
id.gsub!('.', '\.')
|
||||
id.gsub!('|', '\|')
|
||||
id.gsub!('^', '\^')
|
||||
id.gsub!('$', '\$')
|
||||
id.gsub!('+', "\\\\+")
|
||||
id.gsub!(',', '\,')
|
||||
|
||||
id
|
||||
end
|
||||
|
||||
@@ -16,6 +16,9 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
|
||||
$('#id').remove();
|
||||
jQuery("#id").hide();
|
||||
$("[data-placeholder~=name]").remove();
|
||||
$("#cart tr:not(.total_line) > *").remove();
|
||||
$("[href|=\"val\"][href$=\"val\"][href^=\"val\"]").remove();
|
||||
$("tr + td, li").remove();
|
||||
JS
|
||||
|
||||
setup do
|
||||
@@ -32,6 +35,9 @@ class AssertSelectJQueryTest < ActiveSupport::TestCase
|
||||
assert_select 'p', 'something'
|
||||
end
|
||||
assert_select_jquery :remove, "[data-placeholder~=name]"
|
||||
assert_select_jquery :remove, "#cart tr:not(.total_line) > *"
|
||||
assert_select_jquery :remove, "[href|=\"val\"][href$=\"val\"][href^=\"val\"]"
|
||||
assert_select_jquery :remove, "tr + td, li"
|
||||
end
|
||||
|
||||
assert_raise Minitest::Assertion, "No JQuery call matches [:show, :some_wrong]" do
|
||||
|
||||
Reference in New Issue
Block a user