Skip to content

Commit

Permalink
test for evalute optional params
Browse files Browse the repository at this point in the history
  • Loading branch information
sebv committed Sep 14, 2012
1 parent fb70307 commit 1593ddb
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/async/page.coffee
Expand Up @@ -95,6 +95,20 @@ bat = (options) ->
"which return the correct result": (html) ->
html = html.replace(/\s\s+/g, "")
assert.equal html, '<div class="anotherdiv">Some page content</div>'

"can evaluate a script with one param":
topic: t (page) ->
page.evaluate ( (p1) -> "res:#{p1}"), "p12345", (res) => @callback null, res

"which return the correct result": (res) ->
assert.equal res, 'res:p12345'

"can evaluate a script with two params":
topic: t (page) ->
page.evaluate ( (p1, p2) -> "res:#{p1} #{p2}"), "p12345", 678, (res) => @callback null, res

"which return the correct result": (res) ->
assert.equal res, 'res:p12345 678'

"can set a nested property":
topic: t (page) ->
Expand Down
26 changes: 26 additions & 0 deletions test/async/page.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test/sync/page.coffee
Expand Up @@ -73,6 +73,18 @@ test = (options) ->
html.should.equal '<div class="anotherdiv">Some page content</div>'
done()

it "script taking one parameter", (done) ->
Sync ->
res = page.evaluate ( (p1) -> "res:#{p1}" ), 'p12345'
res.should.equal "res:p12345"
done()

it "script taking two parameters", (done) ->
Sync ->
res = page.evaluate ( (p1, p2) -> "res:#{p1} #{p2}" ), 'p12345', 678
res.should.equal "res:p12345 678"
done()

it "setting a nested property", (done) ->
Sync ->
oldVal = page.set 'settings.loadPlugins', true
Expand Down
20 changes: 20 additions & 0 deletions test/sync/page.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1593ddb

Please sign in to comment.