Sha256: 4e86796c4d2c36edabbbb46bed374316129c32cccaea51f296b8767376744cf8

Contents?: true

Size: 1.15 KB

Versions: 11

Compression:

Stored size: 1.15 KB

Contents

var page = new WebPage()
  , url = "http://localhost:3000/tests/index.html"

var fs = require("fs");


function waitFor(testFx, onReady, timeOutMillis) {
  var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 10000
    , start = new Date().getTime()
    , condition = false
    , interval = setInterval(function() {
        var diff = new Date().getTime() - start
        if ( (diff < maxtimeOutMillis) && !condition ) {
          condition = testFx()
        } else {
          if (!condition) {
            console.log("'waitFor()' timeout")
            phantom.exit(1)
          } else {
            console.log("'waitFor()' finished in " + (new Date().getTime() - start) + "ms");
            onReady()
            clearInterval(interval)
          }
        }
      }, 250)
}


page.open(url, function (status) {
  waitFor(function() {
    var result = page.evaluate(function () {
      return document.querySelectorAll('.sink-pass').length
    })
    var result2 = page.evaluate(function () {
        return document.querySelectorAll('.pass').length
      })
    return !!result
  }
, function() {
    console.log("qwery tests have passed")
    phantom.exit(0)
  })
})

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wpa_cli_web-0.0.17 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.15 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.14 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.13 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.12 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.11 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.10 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.9 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.8 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.7 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js
wpa_cli_web-0.0.6 lib/wpa_cli_web/public/bower_components/qwery/tests/phantom.js