mardi 24 avril 2018

How to test a function using jasemine?

I am trying to test function in main file so function , i have sinon to stubbed the function to spy on actual function, i see this error any idea where is the issue for this test case ? ERROR:

s called with wrong params should call getValidator if not passed I D FAILED AssertError: is not a function in

main.ts

public getValidators(): IValidator[] {
        const __this = this;
        if (this.object.IsErrorPresent) {
            return [{
                errorKey: this.objErrorHandler.GetErrorDetails().ErrorDetails.Key as any,
                successCondition: __this.checkIfNoErrorsPresent
            }];
        } else {
            return [];
        }
    }

test.ts

it('should call getValidator if not passed ID', function() {
            // wrong field but a valid value
            const wrongUserParam = {Source: "test",  notId: '123'};

            const validator = module.getValidators();

            sinon.assert.calledWith(validator);

        });

Aucun commentaire:

Enregistrer un commentaire