Untitled
unknown
plain_text
2 years ago
1.2 kB
14
Indexable
it('Deve ser possível inserir uma venda', async function () {
const req = {
body: INSERT_ONE_SALE_MOCK,
};
const res = {
status: sinon.stub().returnsThis(),
json: sinon.stub().returnsThis(),
};
const stub = sinon.stub(salesService, 'insertProductIntoSale').resolves(RESULT_INSERT_ONE_SALE_MOCK);
const stub2 = sinon.stub(salesService, 'getSaleByIdService').resolves(RESULT_NEW_INSERT_ONE_SALE_MOCK);
await salesController.insertSale(req, res);
expect(res.status).to.have.been.calledWith(201);
stub.restore();
stub2.restore();
});
it('Deve ser possível inserir duas vendas', async function () {
const req = {
body: INSERT_TWO_SALES_MOCK,
};
const res = {
status: sinon.stub().returnsThis(),
json: sinon.stub().returnsThis(),
};
const stub = sinon.stub(salesService, 'insertProductIntoSale').resolves(RESULT_INSERT_TWO_SALES_MOCK);
const stub2 = sinon.stub(salesService, 'getSaleByIdService').resolves(RESULT_NEW_INSERT_TWO_SALES_MOCK);
await salesController.insertSale(req, res);
expect(res.status).to.have.been.calledWith(201);
stub.restore();
stub2.restore();
});Editor is loading...
Leave a Comment