phodal/lettuce

View on GitHub
specs/promise-spec.js

Summary

Maintainability
A
1 hr
Test Coverage
'use strict';

describe("Promise", function () {
    var L;

    beforeEach(function () {
        L = new lettuce();
        jasmine.clock().uninstall();
        jasmine.clock().install();
    });

    it("should be use promise patterns", function () {
        function late(n) {
            var p = new L.Promise();
            setTimeout(function() {
                p.done(null, n);
            }, n);
            return p;
        }

        late(10).then(
            function (err, n) {
                expect(n).toEqual(10);
                return late(n + 200);
            }
        ).done();
    });
});