Commit 68e94cf0 authored by yann300's avatar yann300

add more tests

parent bff67fd7
const EventEmitter = require('events')
class ElementIsPresent extends EventEmitter {
command (cssSelector) {
this.api.execute((cssSelector) => {
return !!document.querySelector(cssSelector)
}, [cssSelector], (result) => {
this.api.assert.equal(false, result.value, `${cssSelector} should not be present`)
this.emit('complete')
})
return this
}
}
module.exports = ElementIsPresent
const EventEmitter = require('events')
class ElementIsPresent extends EventEmitter {
command (cssSelector) {
this.api.execute((cssSelector) => {
return !!document.querySelector(cssSelector)
}, [cssSelector], (result) => {
this.api.assert.equal(true, result.value, `${cssSelector} should be present`)
this.emit('complete')
})
return this
}
}
module.exports = ElementIsPresent
......@@ -83,6 +83,28 @@ module.exports = {
.checkElementStyle('.highlightLine40', 'background-color', 'rgb(8, 108, 181)')
.waitForElementPresent('.highlightLine50')
.checkElementStyle('.highlightLine50', 'background-color', 'rgb(8, 108, 181)')
},
'Should remove 1 highlight from source code': function (browser) {
browser.addFile('removeSourcehighlightScript.js', removeSourcehighlightScript)
.switchFile('browser/removeSourcehighlightScript.js')
.executeScript('remix.exeCurrent()')
.switchFile('browser/3_Ballot.sol')
.editorScroll('down', 60)
.elementIsNotPresent('.highlightLine32')
.checkElementStyle('.highlightLine40', 'background-color', 'rgb(8, 108, 181)')
.checkElementStyle('.highlightLine50', 'background-color', 'rgb(8, 108, 181)')
},
'Should remove all highlights from source code': function (browser) {
browser.addFile('removeAllSourcehighlightScript.js', removeAllSourcehighlightScript)
.switchFile('browser/removeAllSourcehighlightScript.js')
.executeScript('remix.exeCurrent()')
.switchFile('browser/3_Ballot.sol')
.editorScroll('down', 60)
.elementIsNotPresent('.highlightLine32')
.elementIsNotPresent('.highlightLine40')
.elementIsNotPresent('.highlightLine50')
.end()
},
......@@ -149,3 +171,27 @@ const sourcehighlightScript = {
})()
`
}
const removeSourcehighlightScript = {
content: `
(async () => {
try {
await remix.call('editor', 'discardHighlightAt', 32, 'browser/3_Ballot.sol')
} catch (e) {
console.log(e.message)
}
})()
`
}
const removeAllSourcehighlightScript = {
content: `
(async () => {
try {
await remix.call('editor', 'discardHighlight')
} catch (e) {
console.log(e.message)
}
})()
`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment