UNPKG

454 BJavaScriptView Raw
1import { expect } from 'chai';
2import sinon from 'sinon';
3
4import graceful from '../../../src/middleware/graceful';
5
6it('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});