heyujie
2021-05-20 6ebdefb4a5b2be82a8c452c0bb4624f3d85a17b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"use strict";
 
var assert         = require("chai").assert
  , ensureThenable = require("../../thenable/ensure");
 
describe("thenable/ensure", function () {
    it("Should return input value", function () {
        var value = { then: function () { return true; } };
        assert.equal(ensureThenable(value), value);
    });
    it("Should crash on no value", function () {
        try {
            ensureThenable({});
            throw new Error("Unexpected");
        } catch (error) {
            assert.equal(error.name, "TypeError");
            assert.equal(error.message, "[object Object] is not a thenable object");
        }
    });
});