From 58bddc040a849f36f840da9b8311ffd0ebd3d6a3 Mon Sep 17 00:00:00 2001 From: Dustin Diaz Date: Thu, 26 May 2011 16:26:12 -0700 Subject: [PATCH] better markdown on readme --- README.md | 78 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index c0fd64d..0fdf400 100644 --- a/README.md +++ b/README.md @@ -8,63 +8,69 @@ Sink test is used to test JavaScript that is run asynchronously whereby you tell How to write a Sink test ------------------------ - test('should have foo', 1, function() { - $.ajax('/foo', function(resp) { - ok(resp.stat == '200'); - }); - }); +``` js +test('should have foo', 1, function() { + $.ajax('/foo', function(resp) { + ok(resp.stat == '200'); + }); +}); +``` Loading a suite of tests ------------------------ The above example illustrates the basic syntax of a single test, however loading your tests is done via the *sink* module which exports the test and ok methods. See the example below: - sink('my module', function(test, ok, before, after) { - before(function () { - // run this before every test - }); +``` js +sink('my module', function(test, ok, before, after) { + before(function () { + // run this before every test + }); - after(function () { - // run this after every test - }); + after(function () { + // run this after every test + }); - test('should have foo', 2, function() { - ok(true, 'this is basically true'); - ok(1 == 1, 'also true for you math majors'); - }); - }); + test('should have foo', 2, function () { + ok(true, 'this is basically true'); + ok(1 == 1, 'also true for you math majors'); + }); +}); - sink('another module', function (t, o, b, a) { - test('a failure', 1, function () { - ok(1 == 2, 'should fail'); - }); - }); +sink('another module', function (t, o, b, a) { + test('a failure', 1, function () { + ok(1 == 2, 'should fail'); + }); +}); - start(); // start all test modules +start(); // start all test modules +``` Browser support --------------- Any browser that supports JavaScript as well as Headless via command line with Node. (see below) - // tests.js - /** this snippet can be found in src/headless.js */ - var sink = require('path/to/sink'); - var start = sink.start; - sink = sink.sink; +``` js +// tests.js +/** this snippet can be found in src/headless.js */ +var sink = require('path/to/sink'); +var start = sink.start; +sink = sink.sink; - sink('some module', function (test, ok) { - // write tests - }); +sink('some module', function (test, ok) { + // write tests +}); - sink('another module', function (test, ok) { - // write tests - }); +sink('another module', function (test, ok) { + // write tests +}); - start(); +start(); +``` in your terminal - % node path/to/my/tests.js + $ node path/to/my/tests.js Happy testing! \ No newline at end of file