UNPKG

630 BJavaScriptView Raw
1'use strict';
2
3var test = require('..').test;
4
5// I'm using Q here, but you can use any Promises/A-compliant library.
6// http://promises-aplus.github.com/promises-spec/
7var Q = require('q');
8
9test('Promise stuff', function (t) {
10 var firstFired, secondFired;
11
12 return Q.all([
13 Q.delay(100).then(function () {
14 firstFired = true;
15 t.ok(!secondFired, 'First comes first');
16 }),
17 Q.delay(150).then(function () {
18 secondFired = true;
19 t.ok(firstFired, 'Second comes second');
20 })
21 ]);
22});
23
24test('Broken promises', function (t) {
25 return Q.fcall(function () {
26 throw new Error('lies');
27 });
28});