<commit_before># jasmine-jquery [![Build Status](https://travis-ci.org/velesin/jasmine-jquery.png)](https://travis-ci.org/velesin/jasmine-jquery)


jasmine-jquery provides two extensions for [Jasmine](http://pivotal.github.com/jasmine/) JavaScript Testing Framework:

- a set of custom matchers for jQuery framework
- an API for handling HTML, CSS, and JSON fixtures in your specs

## Installation

Simply download _jasmine-jquery.js_ from [here](https://raw.github.com/velesin/jasmine-jquery/master/lib/jasmine-jquery.js) and include it in your Jasmine's test runner file (or add it to _jasmine.yml_ file if you're using Ruby with [jasmine-gem](http://github.com/pivotal/jasmine-gem)). Remember to include also jQuery library as jasmine-jquery relies on it.

For Ruby on Rails, use this [gem](https://github.com/travisjeffery/jasmine-jquery-rails) or I recommend to comply with the standard RSpec and Jasmine frameworks dir structure and keep your tests in `spec/javascripts/` dir. I put jasmine-jquery (and other libraries like jasmine-ajax) into `spec/javascripts/helpers` dir (so they are automatically loaded) and fixtures into `spec/javascripts/fixtures` dir.

## jQuery matchers

jasmine-jquery provides following custom matchers (in alphabetical order):

- `toBe(jQuerySelector)`
  - e.g. `expect($('<div id="some-id"></div>')).toBe('div')`
  - e.g. `expect($('<div id="some-id"></div>')).toBe('div#some-id')`
- `toBeChecked()`
  - only for tags that have checked attribute
  - e.g. `expect($('<input type="checkbox" checked="checked"/>')).toBeChecked()`
- `toBeEmpty()`
  - Checks for child DOM elements or text.
- `toBeHidden()`

  Elements can be considered hidden for several reasons:
    - They have a CSS `display` value of `none`.
    - They are form elements with `type` equal to `hidden`.
    - Their `width` and `height` are explicitly set to `0`.
    - An ancestor element is hidden, so the element is not shown on the page.
- `toHaveCss(css)`
  - e.g. `expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({display: "none", margin: "10px"})`
  - e.g. `expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({margin: "10px"})`
- `toBeSelected()`
  - only for tags that have selected attribute
  - e.g. `expect($('<option selected="selected"></option>')).toBeSelected()`
- `toBeVisible()`
  - Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero.
- `toContain(jQuerySelector)`
  - e.g. `expect($('<div><span class="some-class"></span></div>')).toContain('span.some-class')`
- `toBeMatchedBy(jQuerySelector)`
  - Check to see if the set of matched elements matches the given selector
  - e.g.  `expect($('<span></span>').addClass('js-something')).toBeMatchedBy('.js-something')`
- `toExist()`
- `toHaveAttr(attributeName, attributeValue)`
  - attribute value is optional, if omitted it will check only if attribute exists
- `toHaveProp(propertyName, propertyValue)`
  - property value is optional, if omitted it will check only if property exists
- `toHaveBeenTriggeredOn(selector)`
  - if event has been triggered on `selector` (see "Event Spies", below)
- `toHaveBeenTriggered()`
  - if event has been triggered on `selector` (see "Event Spies", below)
- `toHaveBeenTriggeredOnAndWith(selector, extraParameters)`
  - if event has been triggered on `selector` and with `extraParameters`
- `toHaveBeenPreventedOn(selector)`
  - if event has been prevented on `selector` (see "Event Spies", below)
- `toHaveBeenPrevented()`
  - if event has been prevented on `selector` (see "Event Spies", below)
- `toHaveClass(className)`
  - e.g. `expect($('<div class="some-class"></div>')).toHaveClass("some-class")`
- `toHaveData(key, value)`
  - value is optional, if omitted it will check only if an entry for that key exists
- `toHaveHtml(string)`
  - e.g. `expect($('<div><span></span></div>')).toHaveHtml('<span></span>')`
- `toContainHtml(string)`
  - e.g. `expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>')`<commit_msg>Update README docs for v2 (#154)<commit_after># jasmine-jquery [![Build Status](https://travis-ci.org/velesin/jasmine-jquery.png)](https://travis-ci.org/velesin/jasmine-jquery)


jasmine-jquery provides two extensions for [Jasmine](http://pivotal.github.com/jasmine/) JavaScript Testing Framework:

- a set of custom matchers for jQuery framework
- an API for handling HTML, CSS, and JSON fixtures in your specs

## Installation

Simply download _jasmine-jquery.js_ from [here](https://raw.github.com/velesin/jasmine-jquery/master/lib/jasmine-jquery.js) and include it in your Jasmine's test runner file (or add it to _jasmine.yml_ file if you're using Ruby with [jasmine-gem](http://github.com/pivotal/jasmine-gem)). Remember to include also jQuery library as jasmine-jquery relies on it.

For Ruby on Rails, use this [gem](https://github.com/travisjeffery/jasmine-jquery-rails) or I recommend to comply with the standard RSpec and Jasmine frameworks dir structure and keep your tests in `spec/javascripts/` dir. I put jasmine-jquery (and other libraries like jasmine-ajax) into `spec/javascripts/helpers` dir (so they are automatically loaded) and fixtures into `spec/javascripts/fixtures` dir.

## jQuery matchers

jasmine-jquery provides following custom matchers (in alphabetical order):

- `toEqual(jQuerySelector)`
  - e.g. `expect($('<div id="some-id"></div>')).toBe('div')`
  - e.g. `expect($('<div id="some-id"></div>')).toBe('div#some-id')`
- `toBeChecked()`
  - only for tags that have checked attribute
  - e.g. `expect($('<input type="checkbox" checked="checked"/>')).toBeChecked()`
- `toBeEmpty()`
  - Checks for child DOM elements or text.
- `toBeHidden()`

  Elements can be considered hidden for several reasons:
    - They have a CSS `display` value of `none`.
    - They are form elements with `type` equal to `hidden`.
    - Their `width` and `height` are explicitly set to `0`.
    - An ancestor element is hidden, so the element is not shown on the page.
- `toHaveCss(css)`
  - e.g. `expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({display: "none", margin: "10px"})`
  - e.g. `expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({margin: "10px"})`
- `toBeSelected()`
  - only for tags that have selected attribute
  - e.g. `expect($('<option selected="selected"></option>')).toBeSelected()`
- `toBeVisible()`
  - Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero.
- `toContainElement(jQuerySelector)`
  - e.g. `expect($('<div><span class="some-class"></span></div>')).toContain('span.some-class')`
- `toBeMatchedBy(jQuerySelector)`
  - Check to see if the set of matched elements matches the given selector
  - e.g.  `expect($('<span></span>').addClass('js-something')).toBeMatchedBy('.js-something')`
- `toExist()`
- `toHaveAttr(attributeName, attributeValue)`
  - attribute value is optional, if omitted it will check only if attribute exists
- `toHaveProp(propertyName, propertyValue)`
  - property value is optional, if omitted it will check only if property exists
- `toHaveBeenTriggeredOn(selector)`
  - if event has been triggered on `selector` (see "Event Spies", below)
- `toHaveBeenTriggered()`
  - if event has been triggered on `selector` (see "Event Spies", below)
- `toHaveBeenTriggeredOnAndWith(selector, extraParameters)`
  - if event has been triggered on `selector` and with `extraParameters`
- `toHaveBeenPreventedOn(selector)`
  - if event has been prevented on `selector` (see "Event Spies", below)
- `toHaveBeenPrevented()`
  - if event has been prevented on `selector` (see "Event Spies", below)
- `toHaveClass(className)`
  - e.g. `expect($('<div class="some-class"></div>')).toHaveClass("some-class")`
- `toHaveData(key, value)`
  - value is optional, if omitted it will check only if an entry for that key exists
- `toHaveHtml(string)`
  - e.g. `expect($('<div><span></span></div>')).toHaveHtml('<span></span>')`
- `toContainHtml(string)`
  - e.g. `expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>')`
{'fraction_non_alphanumeric': 0.15678846388854945, 'fraction_numerical': 0.0031773188317243063, 'mean_word_length': 4.723076923076923, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '843827', 'n_tokens_mistral': 2617, 'n_tokens_neox': 2530, 'n_words': 798}