pull/1/head
yann300 8 years ago
parent 6017b95993
commit 2b91c6a722
  1. 3
      test-browser/helpers/contracts.js
  2. 20
      test-browser/helpers/dom.js
  3. 30
      test-browser/tests/staticanalysis.js

@ -21,6 +21,7 @@ function testContracts (browser, contractCode, compiledContractNames, callback)
.clearValue('#input textarea')
.click('.newFile')
.setValue('#input textarea', contractCode, function () {})
.waitForElementPresent('.contract .create', 2000)
.waitForElementPresent('.contract .create', 2000, true, function () {
checkCompiledContracts(browser, compiledContractNames, callback)
})
}

@ -0,0 +1,20 @@
'use strict'
module.exports = {
listSelectorContains: listSelectorContains
}
function listSelectorContains (textsToFind, selector, browser, callback) {
browser
.elements('css selector', selector, function (warnings) {
warnings.value.map(function (warning, index) {
browser.elementIdText(warning.ELEMENT, function (text) {
browser.assert.equal(text.value.indexOf(textsToFind[index]) !== -1, true)
if (index === warnings.value.length - 1) {
callback()
}
})
})
})
}

@ -2,6 +2,7 @@
var contractHelper = require('../helpers/contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var dom = require('../helpers/dom')
var sources = {
'sources': {
@ -28,33 +29,22 @@ module.exports = {
tearDown: sauce
}
function findText (browser, selector, textToFind) {
var found = false
browser
.elements('css selector', selector, function (warnings) {
warnings.value.forEach(function (warning) {
browser.elementIdText(warning.ELEMENT, function (text) {
if (text.indexOf(textToFind) >= 0) {
found = true
}
})
})
})
browser.assert.equal(found, true)
}
function runTests (browser) {
browser
.waitForElementVisible('.newFile', 10000)
contractHelper.testContracts(browser, sources.sources.Untitled, ['TooMuchGas', 'test1', 'test2'], function () {
console.log('pppzzz?')
browser
.click('.staticanalysisView')
.click('#staticanalysisView button')
.waitForElementPresent('#staticanalysisresult .warning')
findText(browser, '#staticanalysisresult .warning span',
'Untitled:2:33: use of tx.origin')
findText(browser, '#staticanalysisresult .warning span',
'Fallback function of contract TooMuchGas requires too much gas')
.waitForElementPresent('#staticanalysisresult .warning', 2000, true, function () {
dom.listSelectorContains(['Untitled:1:34: use of tx.origin',
'Fallback function of contract TooMuchGas requires too much gas'],
'#staticanalysisresult .warning span',
browser, function () {
browser.end()
}
)
})
})
}

Loading…
Cancel
Save