| commit | author | age | ||
| 83c3f6 | 1 | Unit tests, written with [QUnit](https://qunitjs.com), are used to |
| SP | 2 | expose bugs for squashing, prevent bugs from respawning, and suppress new |
| 3 | bugs when adding new features and making changes. | |
| 4 | ||
| 5 | # Running the tests | |
| 6 | ||
| 7 | The simplest way to run the tests is to open `tests/tests.html` in your browser. | |
| 8 | The test suites will automatically run themselves and present their results. | |
| 9 | ||
| 10 | To run the tests from the command line (after running jshint and jscs, which is | |
| 11 | recommended), install Grunt and run the `test` task from anywhere within the | |
| 12 | repo: | |
| 13 | ||
| 14 | $ grunt test | |
| 15 | ||
| 16 | # Adding tests | |
| 17 | ||
| 18 | Tests go in js files in the `tests/suites/` directory tree. QUnit organizes | |
| 19 | tests into suites called "modules"; there is one module per js file. If the | |
| 20 | tests you are adding do not fit into an existing module, create a new one at | |
| 21 | `tests/suites/<new module>.js`, where `<new module>` is a broad yet | |
| 22 | descriptive name for the suite. If tests have many year-specific cases (ie, | |
| 23 | behave differently in leap years vs normal years, or have specific buggy | |
| 24 | behavior in a certain year), create the module in a new directory, | |
| 25 | `tests/suites/<new module>/<year>.js`, where `<new module>` is the decriptive | |
| 26 | name and `<year>` is the four-digit year the tests pertain to. | |
| 27 | ||
| 28 | In order for new tests to be run, they must be imported into `tests/tests.html`. | |
| 29 | Find the script includes headed by the html comment `<!-- Test suites -->`, and | |
| 30 | add a new one to the list which includes the new js files. | |