Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.3 KB

Readme.rdoc

File metadata and controls

35 lines (24 loc) · 1.3 KB

Live search, a JavaScript TDD showcase

Read the article: msdn.microsoft.com/en-us/gg650426.aspx

The code itself is very crude - this is just the start of a plugin. Note that it does not do anything other than display a list of suggestions. No keyboard navigation, no ability to select suggestions, no nothing. This is only an example of how I use TDD to develop code - there is only so much you can show in a single article.

To actually take the code for a spin, concatenate the source files like so:

cat client/lib/jquery.js client/src/list_renderer.js\
      client/src/xhr_data_source.js client/src/live_search.js\
      client/src/live_search.jquery.js > server/public/live-search.min.js

Then run the server (you’ll need Node.js 0.4.8 or higher)

cd server
npm link
./run_server

Then visit localhost:8000/ and type something in the search box. Suggestions should show up.

I wish I could tell you that I took the time to TDD the server code as well, but unfortunately, it’s a complete mess, and I only hacked it together in order to show the demo with some results.

To run the tests:

cd client && java -jar path/to/JsTestDriver-1.2.2.jar --tests all

I recommend Jstdutil (cjohansen.no/en/javascript/jstdutil_a_ruby_wrapper_over_jstestdriver).