<?xml version="1.0" encoding="UTF-8"?>
<wiki>
  <body>&lt;p&gt;&lt;strong&gt;Please note: this is incomplete and work in progress!&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Predefined assertions&lt;/h2&gt;
&lt;ul&gt;
	&lt;li&gt;equals(x, y)&lt;/li&gt;
	&lt;li&gt;notEquals(x, y)&lt;/li&gt;
	&lt;li&gt;isTrue(x)&lt;/li&gt;
	&lt;li&gt;isDefined(x)&lt;/li&gt;
	&lt;li&gt;isUndefined(x)&lt;/li&gt;
	&lt;li&gt;isFalse(x)&lt;/li&gt;
	&lt;li&gt;isNull(x)&lt;/li&gt;
	&lt;li&gt;raises(exception, code, context)&lt;/li&gt;
	&lt;li&gt;matches(pattern, string)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;TestCase&lt;/h2&gt;
&lt;h3&gt;constructor(title, opts)&lt;/h3&gt;
&lt;p&gt;Invocation:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
    var case = new TestCase('Widget tests');
    var case = new TestCase('Widget tests', {runStrategy: 'async'});
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Use async run strategy when test cases mustn&amp;#8217;t be run immediately&lt;br /&gt;
after test setup, for example when during setup a document is&lt;br /&gt;
loaded into the browser and the browser will signal when the&lt;br /&gt;
document has finished loading through a callback.&lt;/p&gt;
&lt;p&gt;Note: code inside tests will still run sequentially.  In some&lt;br /&gt;
cases, e.g. testing interfaces, this means you will do something to&lt;br /&gt;
affect the interface and then test the effect, before the interface&lt;br /&gt;
thread has had a chance to apply your request.  Control of flow&lt;br /&gt;
inside tests is work in progress.&lt;/p&gt;
&lt;p&gt;Alias:&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
    var spec = new Specification();
&lt;/code&gt;
&lt;/pre&gt;
&lt;h3&gt;setTests(hash)&lt;/h3&gt;
&lt;p&gt;Define test cases, optionally with setup and teardown.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
    var case = new TestCase();
    case.tests = {
        setUp: function() {
            this.plusFactor = 4;
        },
    
        testOperation: function() {
            assert.equals(8, 2+2+this.plusFactor);
        },
    
        tearDown: function() {
            // release resources if necessary
        }
    }
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Every test is run in a context created ex-novo and accessible from&lt;br /&gt;
the test itself via the &amp;#8216;this&amp;#8217; identifier.&lt;/p&gt;
&lt;p&gt;Aliases: setTests(), &amp;#8216;stateThat&amp;#8217;.  &amp;#8216;setUp&amp;#8217; is also aliased to&lt;br /&gt;
&amp;#8216;given&amp;#8217;.  &amp;#8216;stateThat&amp;#8217; and &amp;#8216;given&amp;#8217; allow a more Behaviour-Driven&lt;br /&gt;
Development style.&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
    var spec = new Specification();
    spec.stateThat = {
        given: function() {
            this.plusFactor = 4;
        },

        'Adding two and two and plus factor yields eight': function() {
            assert.equals(8, 2+2+this.plusFactor);
        },

        tearDown: function() {
            // release resources if necessary
        }
    }
&lt;/code&gt;
&lt;/pre&gt;
&lt;h3&gt;run()&lt;/h3&gt;
&lt;p&gt;Runs tests with strategy defined at construction time.&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
   var case = new TestCase();
   case.tests = { ... };
   case.run();
&lt;/code&gt;
&lt;/pre&gt;
&lt;h3&gt;setUp(fn)&lt;/h3&gt;
&lt;p&gt;Alternative style for defining setup.&lt;/p&gt;
&lt;h3&gt;test(desc, code)&lt;/h3&gt;
&lt;p&gt;Alternative style for defining tests.  Can be called multiple&lt;br /&gt;
times.&lt;/p&gt;
&lt;h3&gt;tearDown(fn)&lt;/h3&gt;
&lt;p&gt;Alternative style for defining teardown.&lt;/p&gt;
&lt;h3&gt;verify()&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;BDD&lt;/span&gt;-style alias for run().&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
   var spec = new Specification();
   spec.stateThat = { ... };
   spec.verify();
&lt;/code&gt;
&lt;/pre&gt;
&lt;h3&gt;given(fn)&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;BDD&lt;/span&gt;-alias for setUp().&lt;/p&gt;
&lt;h3&gt;states(desc, fn)&lt;/h3&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;BDD&lt;/span&gt;-style alias for test().&lt;/p&gt;</body>
  <created-at type="datetime">2008-10-05T10:16:41-07:00</created-at>
  <id type="integer">63753</id>
  <permalink>reference</permalink>
  <repository-id type="integer">56497</repository-id>
  <title>Reference</title>
  <updated-at type="datetime">2008-10-05T10:16:41-07:00</updated-at>
  <user-id type="integer">19322</user-id>
</wiki>
