Untitled

 avatar
unknown
plain_text
a year ago
607 B
5
Indexable
// PRODUCT SERVICE

   describe('getAllProducts', function () {
    it('should return all products', async function () {
      const products: any = [
        { id: 1, name: 'Product 1', price: '10.00', userId: 1 },
        { id: 2, name: 'Product 2', price: '20.00', userId: 1 },
        { id: 3, name: 'Product 3', price: '30.00', userId: 2 },
      ];

      const findAllStub = sinon.stub(ProductModel, 'findAll').resolves(products);

      const result = await createProduct.getAllProducts();

      expect(findAllStub.calledOnce).to.be.true;
      expect(result).to.deep.equal(products);
    });
  });
Editor is loading...
Leave a Comment