All files / app/routes/auth/logout logout-controller.unit.spec.ts

100% Statements 20/20
100% Branches 0/0
100% Functions 4/4
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  1x 1x   1x   1x         1x 1x     1x   1x   1x   1x 1x 1x 1x 1x 1x   1x 1x 1x   1x     1x      
/* eslint-disable @typescript-eslint/no-explicit-any */
import {createSandbox, match} from 'sinon';
import logoutController from './logout-controller';
 
const sandbox = createSandbox();
 
describe('LogoutController', function() {
  let req: any;
  let res: any;
  let next: any;
 
  afterEach(function() {
    sandbox.restore();
  });
 
  it('sets empty jwt token', function(done) {
    // Mock request, response
    req = sandbox.stub();
 
    next = sandbox.stub();
 
    res = sandbox.stub();
    res.setJwtToken = sandbox.stub();
    res.status = sandbox.stub();
    res.send = sandbox.stub().callsFake(function() {
      sandbox.assert.notCalled(req);
      sandbox.assert.notCalled(next);
 
      sandbox.assert.calledOnceWithExactly(res.setJwtToken, match({}));
      sandbox.assert.calledOnceWithExactly(res.status, 204);
      sandbox.assert.calledOnceWithExactly(res.send);
 
      done();
    });
 
    logoutController(req, res, next);
  });
});