tracelytics/pageguide — pull request #34 by arizzitano (2014-01-03 20:49:27+00:00)
Title: Tests v1 and misc. cleanup

This PR adds some primarily functional tests to pageguide, using the markup within the example page. These are certainly not exhaustive but they cover most of its basic use cases (opening/closing, navigating through steps, interacting with the welcome message, etc.). Due to pageguide's asynchronous nature, I had to write a few helper functions to delay test execution, but they still resemble basic QUnit tests for the most part.

I wanted to hold off on writing too many small, specific unit tests for now, since I intend to overhaul pageguide significantly in fixing #28. However, most of this work will be done under the hood, so it will still behave like the pageguide we all know and love (thus, the functional tests, to facilitate further development).

In addition to the new tests, it also adds a few things to pageguide.js:
- Wrap entire body in closure and use $ for jQuery
- Add `ready_callback` to the `tl.pg.init` options, allowing a callback to run on `pg.ready()`. This is primarily useful for running async tests, but could also help users trigger other actions once pageguide is ready.
- Define markup for the guide and toggle within contiguous blocks before appending to the DOM. This makes this markup much easier to read, understand, and edit.
- Add `tl.pg.destroy()` method, to remove all pageguide-associated DOM elements.
- Automatically wrap `#tlyPageGuide` step text within container divs to cut down on the amount of markup required for the user to include.
- Class the `ins` elements appended for step indices for easy reference and removal
- Replace all contextual selections with `find()`, for [performance reasons](http://jsperf.com/jquery-find-vs-context-2)