File: configurable-promiseness-transfer.js

package info (click to toggle)
node-chai-as-promised 7.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 244 kB
  • sloc: makefile: 2; sh: 1
file content (22 lines) | stat: -rw-r--r-- 781 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"use strict";
require("./support/setup.js");
const chaiAsPromised = require("..");
const originalTransferPromiseness = require("..").transferPromiseness;

describe("Configuring the way in which promise-ness is transferred", () => {
    afterEach(() => {
        chaiAsPromised.transferPromiseness = originalTransferPromiseness;
    });

    it("should return a promise with the custom modifications applied", () => {
        chaiAsPromised.transferPromiseness = (assertion, promise) => {
            assertion.then = promise.then.bind(promise);
            assertion.isCustomized = true;
        };

        const promise = Promise.resolve("1234");
        const assertion = promise.should.become("1234");

        assertion.should.have.property("isCustomized", true);
    });
});