mirror of
https://github.com/zhigang1992/viff.git
synced 2026-04-29 05:05:30 +08:00
check if the path have a pre handler. Qiu
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
module.exports = {
|
||||
seleniumHost: 'http://localhost:4444/wd/hub',
|
||||
browsers: ['firefox', 'chrome'],
|
||||
browsers: ['firefox', 'safari'],
|
||||
envHosts: {
|
||||
build: 'http://localhost:4000',
|
||||
prod: 'http://www.ishouldbeageek.me'
|
||||
|
||||
@@ -4,7 +4,9 @@ module.exports = (function initLinks() {
|
||||
|
||||
return [
|
||||
'/404.html',
|
||||
'/'
|
||||
['/', function (driver, webdriver) {
|
||||
// driver.findElement(webdriver.By.partialLinkText('Subscribe')).click();
|
||||
}]
|
||||
];
|
||||
|
||||
})();
|
||||
|
||||
@@ -19,8 +19,10 @@ class Viff
|
||||
@drivers[browserName] = driver
|
||||
|
||||
envName = _.first(envName for envName of envHost)
|
||||
driver.get envHost[envName] + url
|
||||
[url, preHandle] = url if _.isArray url
|
||||
|
||||
driver.get envHost[envName] + url
|
||||
preHandle driver, webdriver if _.isFunction preHandle
|
||||
driver.takeScreenshot().then (base64Img) ->
|
||||
defer.resolve base64Img
|
||||
|
||||
@@ -39,6 +41,7 @@ class Viff
|
||||
compares[browser] = compares[browser] || {}
|
||||
|
||||
_.each links, (url) ->
|
||||
url = _.first url if _.isFunction url[1]
|
||||
envCompares = {}
|
||||
|
||||
_.each envHosts, (host, env) ->
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Viff = require '../../lib/viff.js'
|
||||
sinon = require 'sinon'
|
||||
_ = require 'underscore'
|
||||
webdriver = require 'selenium-webdriver'
|
||||
|
||||
module.exports =
|
||||
setUp: (callback) ->
|
||||
@@ -65,6 +66,25 @@ module.exports =
|
||||
test.ok callback.calledWith 'base64string'
|
||||
test.done()
|
||||
|
||||
'it should invoke pre handler before take screenshot': (test) ->
|
||||
envHost =
|
||||
build: 'http://localhost:4000'
|
||||
|
||||
preHandler = sinon.spy()
|
||||
|
||||
link = ['/path', preHandler]
|
||||
@viff.takeScreenshot('firefox', envHost, link)
|
||||
|
||||
test.ok preHandler.calledWith @driver, webdriver
|
||||
test.done()
|
||||
|
||||
'it should use correct path when set pre handler': (test) ->
|
||||
links = [['/404.html', (driver, webdriver) -> ]]
|
||||
callback = (compares) ->
|
||||
test.equals _.first(_.keys(compares.firefox)), '/404.html'
|
||||
test.done()
|
||||
@viff.takeScreenshots @config.browsers, @config.compare, links, callback
|
||||
|
||||
'it should take many screenshots according to config': (test) ->
|
||||
format =
|
||||
safari:
|
||||
|
||||
Reference in New Issue
Block a user