Skip to content

Commit

Permalink
Test _js_comment
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed May 21, 2015
1 parent a6a0cde commit 110d551
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/angular_webdriver/protractor/protractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def waitForAngular opt_description='' # Protractor.prototype.waitForAngular
# must use /* */ not // due to some browsers having problems
# with // comments when used with execute script
def _js_comment description
description = description ? '/* ' + description.gsub(/\W+/, ' ') + ' */' : ''
description = description ? '/* ' + description.gsub(/\s+/, ' ').strip + ' */' : ''
description.strip + "\n"
end

Expand Down
46 changes: 28 additions & 18 deletions spec/protractor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def angular_not_found_error
[error_class, error_message]
end

def expect_equal actual, expected
expect(actual).to eq(expected)
end

it 'root_element' do
expect(protractor.root_element).to eq('body')

Expand Down Expand Up @@ -101,24 +105,6 @@ def angular_not_found_error
expect { driver.navigate.refresh }.to_not raise_error
end

=begin
todo: write tests for:
sync
waitForAngular
_js_comment
executeAsyncScript_
executeScript_
debugger
driver
driver
root_element
ignore_sync
client_side_scripts
reset_url
reset_url
base_url
=end

def expect_angular_not_found &block
expect { block.call }.to raise_error(*angular_not_found_error)
end
Expand Down Expand Up @@ -210,4 +196,28 @@ def expect_no_error &block

wait(timeout: 15) { protractor.waitForAngular }
end

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

expect_equal actual, expected
end
end


=begin
todo: write tests for:
executeAsyncScript_
executeScript_
debugger
driver
driver
root_element
ignore_sync
client_side_scripts
reset_url
reset_url
base_url
=end

0 comments on commit 110d551

Please sign in to comment.