• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ialopezg / corejs / #5

03 Nov 2023 08:38PM UTC coverage: 42.153% (-47.5%) from 89.623%
#5

push

ialopezg
feat: add microservice feature

10 of 84 branches covered (0.0%)

Branch coverage included in aggregate %.

49 of 77 new or added lines in 20 files covered. (63.64%)

155 existing lines in 21 files now uncovered.

221 of 464 relevant lines covered (47.63%)

0.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

44.0
/src/core/test/exceptions/handler.spec.ts
1
import { expect } from 'chai';
1✔
2
import * as sinon from 'sinon';
1✔
3

4
import { ExceptionHandler, HttpException } from '../../exceptions';
1✔
5
import { LoggerService } from '../../../common';
1✔
6
import { ApplicationMode } from '../../../common/enums/application-mode.enum';
1✔
7

8
describe('ExceptionsHandler', () => {
1✔
9
  let handler: ExceptionHandler;
10
  let statusStub: sinon.SinonStub;
11
  let jsonStub: sinon.SinonStub;
12
  let response: any;
13

14
  before(() => LoggerService.setMode(ApplicationMode.TEST));
1✔
15

16
  beforeEach(() => {
1✔
UNCOV
17
    handler = new ExceptionHandler();
×
UNCOV
18
    statusStub = sinon.stub();
×
UNCOV
19
    jsonStub = sinon.stub();
×
20

UNCOV
21
    response = {
×
22
      status: statusStub,
23
      json: jsonStub,
24
    };
UNCOV
25
    response.status.returns(response);
×
UNCOV
26
    response.json.returns(response);
×
27
  });
28

29
  describe('next', () => {
1✔
30

31
    it('should method send expected response status code and message when exception is unknown', () => {
1✔
UNCOV
32
      handler.next(new Error(), response);
×
33

UNCOV
34
      expect(statusStub.calledWith(500)).to.be.true;
×
UNCOV
35
      expect(jsonStub.calledWith({ message: 'Unknown exception' })).to.be.true;
×
36
    });
37

38
    it('should method send expected response status code and message when exception is instance of HttpException', () => {
1✔
UNCOV
39
      const status = 401;
×
UNCOV
40
      const message = 'Unauthorized';
×
41

UNCOV
42
      handler.next(new HttpException(message, status), response);
×
43

UNCOV
44
      expect(statusStub.calledWith(status)).to.be.true;
×
UNCOV
45
      expect(jsonStub.calledWith({ message })).to.be.true;
×
46
    });
47
  });
48
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc