Commit cd6cdac4 authored by ioedeveloper's avatar ioedeveloper

Added solidityUnit tests

parent 307715b4
import { NightwatchBrowser } from "nightwatch" import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from "events" import EventEmitter from 'events'
class clearEditablecontent extends EventEmitter { class clearEditablecontent extends EventEmitter {
command (this: NightwatchBrowser, cssSelector): NightwatchBrowser { command (this: NightwatchBrowser, cssSelector): NightwatchBrowser {
......
import { NightwatchBrowser } from 'nightwatch'
import EventEmitter from 'events'
class ClickElement extends EventEmitter {
command (this: NightwatchBrowser, cssSelector: string, index = 0): NightwatchBrowser {
this.api.perform((done) => {
_clickElement(this.api, cssSelector, index, () => {
done()
this.emit('complete')
})
})
return this
}
}
function _clickElement (browser: NightwatchBrowser, cssSelector: string, index: number, cb: VoidFunction) {
browser.waitForElementPresent(cssSelector)
.execute(function (cssSelector: string, index: number) {
const elem = document.querySelectorAll(cssSelector)[index] as HTMLElement
elem.click()
}, [cssSelector, index], function () {
cb()
})
}
module.exports = ClickElement
import { NightwatchBrowser } from "nightwatch"
import EventEmitter from "events"
class NotContainsText extends EventEmitter {
command (this: NightwatchBrowser, cssSelector: string, text: string): NightwatchBrowser {
const browser = this.api
browser.getText(cssSelector, (result) => {
if (typeof result.value === 'string' && result.value.includes(text)) return this.api.assert.fail(`${cssSelector} contains ${text}.`)
else this.api.assert.ok(true, `${cssSelector} does not contains ${text}.`)
})
.perform(() => {
this.emit('complete')
})
return this
}
}
module.exports = NotContainsText
This diff is collapsed.
...@@ -45,7 +45,9 @@ declare module "nightwatch" { ...@@ -45,7 +45,9 @@ declare module "nightwatch" {
switchBrowserWindow(url: string, windowName: string, cb: (browser: NightwatchBrowser, window?: NightwatchCallbackResult<Window>) => void): NightwatchBrowser, switchBrowserWindow(url: string, windowName: string, cb: (browser: NightwatchBrowser, window?: NightwatchCallbackResult<Window>) => void): NightwatchBrowser,
setupMetamask(passphrase: string, password: string): NightwatchBrowser, setupMetamask(passphrase: string, password: string): NightwatchBrowser,
signMessage(msg: string, callback: (hash: { value: string }, signature: { value: string }) => void): NightwatchBrowser, signMessage(msg: string, callback: (hash: { value: string }, signature: { value: string }) => void): NightwatchBrowser,
setSolidityCompilerVersion(version: string): NightwatchBrowser setSolidityCompilerVersion(version: string): NightwatchBrowser,
clickElementAtPosition(cssSelector: string, index: number): NightwatchBrowser,
notContainsText(cssSelector: string, text: string): NightwatchBrowser
} }
export interface NightwatchBrowser { export interface NightwatchBrowser {
......
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