mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Update test and add new view with_jquery_animation
This commit is contained in:
parent
6b5476cc5b
commit
f95e581821
2 changed files with 38 additions and 0 deletions
24
lib/capybara/spec/views/with_jquery_animation.erb
Normal file
24
lib/capybara/spec/views/with_jquery_animation.erb
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
||||
<title>with_jquery_animation</title>
|
||||
<style>
|
||||
body {
|
||||
height: 2000px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body id="with_animation">
|
||||
<a href="#" id='scroll'>scroll top 500</a>
|
||||
|
||||
<script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script type='text/javascript'>
|
||||
$('#scroll').click(function(e){
|
||||
e.preventDefault();
|
||||
$('html, body').animate({ scrollTop: 500 }, 'slow');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -411,6 +411,13 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|||
JS
|
||||
expect(scroll_y).to eq 500
|
||||
end
|
||||
|
||||
it 'should scroll the page instantly without jquery animation', requires: [:js] do
|
||||
@animation_session.visit('with_jquery_animation')
|
||||
@animation_session.click_link('scroll top 500')
|
||||
scroll_y = @animation_session.evaluate_script('window.scrollY')
|
||||
expect(scroll_y).to eq 500
|
||||
end
|
||||
end
|
||||
|
||||
context 'when set to `false`' do
|
||||
|
@ -433,6 +440,13 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|||
# measured over 0.5 seconds: 0, 75, 282, 478, 500
|
||||
expect(scroll_y).to be < 500
|
||||
end
|
||||
|
||||
it 'should scroll the page with jquery animation', requires: [:js] do
|
||||
@animation_session.visit('with_jquery_animation')
|
||||
@animation_session.click_link('scroll top 500')
|
||||
scroll_y = @animation_session.evaluate_script('window.scrollY')
|
||||
expect(scroll_y).to be < 500
|
||||
end
|
||||
end
|
||||
|
||||
context 'if we pass in css that matches elements' do
|
||||
|
|
Loading…
Reference in a new issue