Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.1 kB
4
Indexable
Never
  it('Deve retornar um produto pelo id utilizando a connection mockada', async function () {
    const stub = sinon.stub(connection, 'execute').resolves([SALES_MOCK]);

    const products = await salesModel.findSaleById(1);

    expect(products).to.be.an('array');
    expect(products).to.be.deep.equal(SALES_MOCK);

    stub.restore();
  });

  it('Deve retornar todos os produtos utilizando a connection mockada', async function () {
    const stub = sinon.stub(connection, 'execute').resolves([SALES_MOCK]);

    const products = await salesModel.getAllSales();

    expect(products).to.be.an('array');
    expect(products).to.be.deep.equal(SALES_MOCK);

    stub.restore();
  });

  it('Deve ser possível inserir um produto utilizando a connection mockada', async function () {
    const stub = sinon.stub(connection, 'execute').resolves([SALES_MOCK]);

    const products = await salesModel.insertNewSale(INSERT_ONE_SALE_MOCK);

    expect(products).to.be.an('array');
    expect(products).to.be.deep.equal(SALES_MOCK);

    stub.restore();
  });
Leave a Comment