Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
607 B
1
Indexable
Never
// 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);
    });
  });
Leave a Comment