function getMocks () { const req = { headers: {}, query: {}, body: {}, get: function (header) { return this.headers[header]; } }; sinon.spy(req, 'get'); const res = { headers: {}, send: sinon.stub().returnsThis(), json: sinon.stub().returnsThis(), end: sinon.stub().returnsThis(), status: function (statusCode) { this.statusCode = statusCode; return this; }, set: function (header, value) { this.headers[header] = value; return this; } }; sinon.spy(res, 'status'); sinon.spy(res, 'set'); return { req: req, res: res }; }
it(`loads scoped package containing path`, () => { const requireMethod = sinon.spy() const load = presetLoader(requireMethod) load(`@scope/angular/preset/path`) expect(requireMethod).to.have.been.calledOnce .and.to.have.been.calledWith(`@scope/conventional-changelog-angular/preset/path`) })
it(`loads unscoped package`, () => { const requireMethod = sinon.spy() const load = presetLoader(requireMethod) load(`angular`) expect(requireMethod).to.have.been.calledOnce .and.to.have.been.calledWith(`conventional-changelog-angular`) })
function getMocks () { const req = { headers: {}, get: function (header) { return this.headers[header]; } }; sinon.spy(req, `get`); return { req: req, res: { send: sinon.stub().returnsThis(), json: sinon.stub().returnsThis(), end: sinon.stub().returnsThis(), status: sinon.stub().returnsThis() } }; }