alfateam123/md2bbc — pull request #10 by alfateam123 (2014-05-10 21:42:39+00:00)
Title: Tests - First merge

### wut?
The *test* branch is meant to be modified when new tests are created or tests are fixed.
It __must__ not be closed, and NO PATCH FOR EXISTING CODE MUST BE PRESENT HERE.

Tests are contained in the folder `tests`.
A user can launch them opening `tests/test.html`: a script inside `tests/testloader.js` will start and generate a neat table that informs the user about the correctness of the actual code in `src/showdown.js`

#### y u no node.js?
'cause I don't want to install it in several environments (and I don't think it's cygwin-friendly), and I prefer vanilla.js: it's faster and lightweight! :P
also, I need a way to easily see which part of the library are working and which not, and I want the user to be able to see that just looking at a webpage.

#### wanna write a test!
an test_example.js could look like this one
```js
loadTests({
description: "actual description of the test", //a description, it will be shown in the previous table
starting_text: ["some *sort*", "of test"], //the strings you pass to showdown.js to be processed
expected: ["some [cur]sort[/cur]", "of test"], //the strings you expect showdown.js will return to your client code
options: null //in case you have to test showdown.js under particular condition
});
```
you can pass to `loadTests` an array containing more than one test.

After you wrote it and put it in a file called, for example, `tests/test_example.js`, you have to include it in `tests/test.html`, as a normal js script: this way, when you run the web page, you'll see the result of the test(s).

#### can't see the test cases!
1. open the console
2. run `failingMatches(#test_index)` and explore the array this function gives to you. this way, you can see which test cases are failing and say why comparing the `exp` and `got` fields.