Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed May 11, 2020
1 parent bff67fd commit 23c7c87
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test-browser/commands/elementIsNotPresent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const EventEmitter = require('events')

class ElementIsPresent extends EventEmitter {
command (cssSelector) {
this.api.execute(function (cssSelector) {
return !!document.querySelector(cssSelector)
}, [cssSelector], function (result) {
this.api.assert.equal(false, result.value, `${cssSelector} should not be present`)
this.emit('complete')
})
return this
}
}

module.exports = ElementIsPresent
15 changes: 15 additions & 0 deletions test-browser/commands/elementIsPresent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const EventEmitter = require('events')

class ElementIsPresent extends EventEmitter {
command (cssSelector) {
this.api.execute(function (cssSelector) {
return !!document.querySelector(cssSelector)
}, [cssSelector], function (result) {
this.api.assert.equal(true, result.value, `${cssSelector} should be present`)
this.emit('complete')
})
return this
}
}

module.exports = ElementIsPresent
46 changes: 46 additions & 0 deletions test-browser/tests/editor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},

Expand Down Expand Up @@ -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)
}
})()
`
}

0 comments on commit 23c7c87

Please sign in to comment.