Skip to content

Commit

Permalink
Test executeAsyncScript_
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed May 21, 2015
1 parent 110d551 commit 70c9813
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions spec/protractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,65 @@ def expect_no_error &block
end

it '_js_comment' do
comment = " \n\n Hello\n\r\nThere!\n "
actual = protractor._js_comment comment
comment = " \n\n Hello\n\r\nThere!\n "
actual = protractor._js_comment comment
expected = "/* Hello There! */\n"

expect_equal actual, expected
end

def async_no_arg
(<<-'JS').freeze
return (function (callback) {
callback("hello");
})(arguments[0]);
JS
end

def async_one_arg
(<<-'JS').freeze
return (function (one, callback) {
callback(one);
}).apply(this, arguments);;
JS
end

def async_two_arg
(<<-'JS').freeze
return (function (one, two, callback) {
callback(one + two);
}).apply(this, arguments);;
JS
end

it 'executeAsyncScript_' do
actual = protractor.executeAsyncScript_ async_no_arg, 'comment'
expected = 'hello'
expect_equal actual, expected

actual = protractor.executeAsyncScript_ async_one_arg, 'comment', 1
expected = 1
expect_equal actual, expected

actual = protractor.executeAsyncScript_ async_two_arg, 'comment', 1, 2
expected = 3
expect_equal actual, expected

# the following two tests are copied from selenium ruby
# https://github.com/SeleniumHQ/selenium/blob/ac2a47eb03e32e81c61db641e9a0ae3c4ebcc0fd/rb/spec/integration/selenium/webdriver/driver_spec.rb#L264
actual = protractor.executeAsyncScript_ "arguments[arguments.length - 1]([null, 123, 'abc', true, false]);", 'comment'
expected = [nil, 123, 'abc', true, false]
expect_equal actual, expected

actual = protractor.executeAsyncScript_ 'arguments[arguments.length - 1](arguments[0] + arguments[1]);', 'comment', 1, 2
expected = 3
expect_equal actual, expected
end
end


=begin
todo: write tests for:
executeAsyncScript_
executeScript_
debugger
driver
Expand Down

0 comments on commit 70c9813

Please sign in to comment.