3

Here is my Node unit test-case for a DAO method that returns a list of Category objects. Category is the name of my model. However, when I run this code, it is getting stuck.

describe('findAllCategories', function () {
    it('should find all categoriess', function () {
        var stub = sinon.stub(Category, 'find');
        stub.callsFake(() => {
            return Promise.resolve(allCat);
        });
        categoryDao.findAllCategories().then(response => {
            assert.lengthOf(response, 1);
        })
            .catch((error) => {
                console.log(error);
                assert.isDefined(error);
            });
        stub.callsFake(() => {
            return Promise.reject('');
        });
        categoryDao.findAllCategories().then(response => {
            assert.lengthOf(response, 1);
        }).catch((err) => {
            console.log(err);
            assert.isDefined(err);
        });
    });
});

Any way around?

joler-botol
  • 442
  • 1
  • 7
  • 22

0 Answers0