<commit_before>// 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{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  this.expected = count{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  this.pass = function (val) {
    return val === this.expected{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  }
  this.value = function (res) {
    return res.value{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  }
  this.command = function (cb) {
    var self = this{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
    return this.api.execute(function (selector) {
      return document.querySelectorAll(selector).length{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
    }, [selector], function (res) {
      cb.call(self, res){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
    }){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  }
}<commit_msg>Simplify elementCount custom assertions (#898)<commit_after>// A custom Nightwatch assertion.
// The assertion name is the filename.
// Example usage:
//
//   browser.assert.elementCount(selector, count)
//
// For more information on custom assertions see:
// http://nightwatchjs.org/guide#writing-custom-assertions

exports.assertion = function (selector, count) {
  this.message = 'Testing if element <' + selector + '> has count: ' + count{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  this.expected = count{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  this.pass = function (val) {
    return val === this.expected{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  }
  this.value = function (res) {
    return res.value{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  }
  this.command = function (cb) {
    var self = this{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
    return this.api.execute(function (selectorToCount) {
      return document.querySelectorAll(selectorToCount).length{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
    }, [selector], function (res) {
      cb.call(self, res){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
    }){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
  }
}
{'fraction_non_alphanumeric': 0.1828471919895516, 'fraction_numerical': 0.00130605137135394, 'mean_word_length': 4.234624145785877, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6032363', 'n_tokens_mistral': 832, 'n_tokens_neox': 818, 'n_words': 173}