Skip to content

Commit

Permalink
[fix doc] Remove all mention of the word "promise". Fixes #3.
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Nov 26, 2014
1 parent abce2e8 commit 6ef9018
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions content/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,20 +273,20 @@ hasn't returned.
> Note that topics which make use of '`this.callback`' must not return anything. And likewise, topics
which do not return anything must make use of '`this.callback`'.

### Promises #
### EventEmitters #

Vows also supports promise-based async out of the box, so if that works better for your purpose,
Vows also supports EventEmitter-based async out of the box, so if that works better for your purpose,
you can return an instance of `EventEmitter` from a topic, and the tests will be run when it
emits a `"success"` or `"error"` event:

{ topic: function () {
var promise = new(events.EventEmitter);
var emitter = new(events.EventEmitter);

fs.stat('~/FILE', function (e, res) {
if (e) { promise.emit('error', e) }
else { promise.emit('success', res) }
if (e) { emitter.emit('error', e) }
else { emitter.emit('success', res) }
});
return promise;
return emitter;
},
'can be accessed': function (err, stat) {
assert.isNull (err); // We have no error
Expand Down
4 changes: 2 additions & 2 deletions partials/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ <h3>
<pre class="command">$ vows test/* --spec</pre>
<p>Get the report, make sure you kept your word.</p>
<pre>
A non-promise return value
&#10003; <span class="vow">should be converted to a promise</span>
A non-EventEmitter return value
&#10003; <span class="vow">should be converted to an EventEmitter</span>
A topic not emitting an error
&#10003; <span class="vow">should pass null if the test is expecting an error</span>
&#10003; <span class="vow">should pass the result otherwise</span>
Expand Down
16 changes: 8 additions & 8 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ <h3>
<pre class="command">$ vows test/* --spec</pre>
<p>Get the report, make sure you kept your word.</p>
<pre>
A non-promise return value
&#10003; <span class="vow">should be converted to a promise</span>
A non-EventEmitter return value
&#10003; <span class="vow">should be converted to an EventEmitter</span>
A topic not emitting an error
&#10003; <span class="vow">should pass null if the test is expecting an error</span>
&#10003; <span class="vow">should pass the result otherwise</span>
Expand Down Expand Up @@ -456,18 +456,18 @@ <h2 id="writing-asynchronous-tests">Writing asynchronous tests</h2>
<p>Note that topics which make use of &#39;<code>this.callback</code>&#39; must not return anything. And likewise, topics
which do not return anything must make use of &#39;<code>this.callback</code>&#39;.</p>
</blockquote>
<h3 id="promises">Promises</h3>
<p>Vows also supports promise-based async out of the box, so if that works better for your purpose,
<h3 id="eventemitters">EventEmitters</h3>
<p>Vows also supports EventEmitter-based async out of the box, so if that works better for your purpose,
you can return an instance of <code>EventEmitter</code> from a topic, and the tests will be run when it
emits a <code>&quot;success&quot;</code> or <code>&quot;error&quot;</code> event:</p>
<pre><code>{ topic: function () {
var promise = new(events.EventEmitter);
var emitter = new(events.EventEmitter);

fs.stat(&#39;~/FILE&#39;, function (e, res) {
if (e) { promise.emit(&#39;error&#39;, e) }
else { promise.emit(&#39;success&#39;, res) }
if (e) { emitter.emit(&#39;error&#39;, e) }
else { emitter.emit(&#39;success&#39;, res) }
});
return promise;
return emitter;
},
&#39;can be accessed&#39;: function (err, stat) {
assert.isNull (err); // We have no error
Expand Down

0 comments on commit 6ef9018

Please sign in to comment.