dimanche 22 octobre 2017

Issues creating a Unit Test stub for this function return using Sinon and Should

I have the following health.js file..

exports.endpoint = function (req, res) {
    let http_status = 200;
    res.sendStatus(http_status);
};

Where I'm trying to figure out how I can create a Unit Test from this endpoint.

Below is my attempt so far..

import { sinon, should } from "../../test-harness";

let health = require('../../../src/endpoints/health');
health.endpoint = sinon.stub();

describe('The health endpoint', function () {
    it('should call .endpoint()', () => {
        health.endpoint.should.have.been.called;
    });
});

But it seems to be passing regardless of if I add a .not to my should.have.been.called statement.

Where am I going wrong?

Aucun commentaire:

Enregistrer un commentaire