aboutsummaryrefslogtreecommitdiffstats
path: root/test/e2e/custom-assertions/elementCount.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2017-01-15 18:24:09 -0800
committerAdam Soltys <[email protected]>2017-01-15 18:24:09 -0800
commit7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e (patch)
tree91bb1d1b8fe6ad77a48f0e429d9bfd35834c78d9 /test/e2e/custom-assertions/elementCount.js
parent0ae266bf88f9f79c7e99b272688126898303daa4 (diff)
downloadcoinos-server-7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e.tar.gz
coinos-server-7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e.zip
Initial Vueification
Diffstat (limited to 'test/e2e/custom-assertions/elementCount.js')
-rw-r--r--test/e2e/custom-assertions/elementCount.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/e2e/custom-assertions/elementCount.js b/test/e2e/custom-assertions/elementCount.js
new file mode 100644
index 00000000..c0d5fe00
--- /dev/null
+++ b/test/e2e/custom-assertions/elementCount.js
@@ -0,0 +1,26 @@
+// A custom Nightwatch assertion.
+// the name of the method is the filename.
+// can be used in tests like this:
+//
+// browser.assert.elementCount(selector, count)
+//
+// for how to write custom assertions see
+// http://nightwatchjs.org/guide#writing-custom-assertions
+exports.assertion = function (selector, count) {
+ this.message = 'Testing if element <' + selector + '> has count: ' + count
+ this.expected = count
+ this.pass = function (val) {
+ return val === this.expected
+ }
+ this.value = function (res) {
+ return res.value
+ }
+ this.command = function (cb) {
+ var self = this
+ return this.api.execute(function (selector) {
+ return document.querySelectorAll(selector).length
+ }, [selector], function (res) {
+ cb.call(self, res)
+ })
+ }
+}