logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

elementCount.js (779B)


  1. // A custom Nightwatch assertion.
  2. // the name of the method is the filename.
  3. // can be used in tests like this:
  4. //
  5. // browser.assert.elementCount(selector, count)
  6. //
  7. // for how to write custom assertions see
  8. // http://nightwatchjs.org/guide#writing-custom-assertions
  9. exports.assertion = function (selector, count) {
  10. this.message = 'Testing if element <' + selector + '> has count: ' + count
  11. this.expected = count
  12. this.pass = function (val) {
  13. return val === this.expected
  14. }
  15. this.value = function (res) {
  16. return res.value
  17. }
  18. this.command = function (cb) {
  19. const self = this
  20. return this.api.execute(function (selector) {
  21. return document.querySelectorAll(selector).length
  22. }, [selector], function (res) {
  23. cb.call(self, res)
  24. })
  25. }
  26. }