add more tests

uiCheck
yann300 5 years ago
parent bff67fd7a4
commit 68e94cf087
  1. 15
      test-browser/commands/elementIsNotPresent.js
  2. 15
      test-browser/commands/elementIsPresent.js
  3. 46
      test-browser/tests/editor.test.js

@ -0,0 +1,15 @@
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

@ -0,0 +1,15 @@
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)') .checkElementStyle('.highlightLine40', 'background-color', 'rgb(8, 108, 181)')
.waitForElementPresent('.highlightLine50') .waitForElementPresent('.highlightLine50')
.checkElementStyle('.highlightLine50', 'background-color', 'rgb(8, 108, 181)') .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() .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)
}
})()
`
}

Loading…
Cancel
Save