File: custom-messages.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 (43 lines) | stat: -rw-r--r-- 1,424 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
require("./support/setup.js");
const shouldPass = require("./support/common.js").shouldPass;
const shouldFail = require("./support/common.js").shouldFail;

describe("Custom messages", () => {
    let promise = null;
    const message = "He told me enough! He told me you killed him!";

    beforeEach(() => {
        promise = Promise.resolve(42);
    });

    describe("should pass through for .become(value, message) for 42", () => {
        shouldPass(() => promise.should.become(42, message));
    });
    describe("should pass through for .become(value, message) for 52", () => {
        shouldFail({
            op: () => promise.should.become(52, message),
            message
        });
    });

    describe("should pass through for .not.become(42, message)", () => {
        shouldFail({
            op: () => promise.should.not.become(42, message),
            message
        });
    });
    describe("should pass through for .not.become(52, message)", () => {
        shouldPass(() => promise.should.not.become(52, message));
    });

    describe("should pass through for .eventually.equal(42)", () => {
        shouldPass(() => promise.should.eventually.equal(42, message));
    });
    describe("should pass through for .not.eventually.equal(42)", () => {
        shouldFail({
            op: () => promise.should.not.eventually.equal(42, message),
            message
        });
    });
});