1 | import { expect } from 'chai';
|
2 | import sinon from 'sinon';
|
3 |
|
4 | import graceful from '../../../src/middleware/graceful';
|
5 |
|
6 | it('should 502 when server is shutting down', () => {
|
7 | const stub = sinon.stub();
|
8 | const spy = sinon.spy();
|
9 | const app = graceful()({ request: spy });
|
10 | const res = { setHeader: stub, end: stub };
|
11 | app.request({ socket: { _handle: null }}, res);
|
12 | expect(res).to.have.property('statusCode', 502);
|
13 | expect(spy).not.to.be.called;
|
14 | });
|