remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/test-browser/commands/checkElementStyle.js

27 lines
788 B

const EventEmitter = require('events')
class checkElementStyle extends EventEmitter {
command (cssSelector, styleProperty, expectedResult) {
this.api.perform((done) => {
checkStyle(this.api, cssSelector, styleProperty, expectedResult, () => {
done()
this.emit('complete')
})
})
return this
}
}
function checkStyle (browser, cssSelector, styleProperty, expectedResult, callback) {
browser.execute(function (cssSelector, styleProperty) {
return window.getComputedStyle(document.querySelector(cssSelector)).getPropertyValue(styleProperty)
}, [cssSelector, styleProperty], function (result) {
const value = result.value
browser.assert.equal(value.trim(), expectedResult)
callback()
})
}
module.exports = checkElementStyle