I am using lodash library in my angular application for trimming text box value.
The code am using like this This is working fine when i run the app.
import _ from 'lodash';
validateForm() {
if(_.trim(this.addusermodel.firstname) == "") {
////
}
}
in spec file am using this code
describe('validateForm', () => {
it('Form should validate', () => {
component.addusermodel.firstname = "wrwer";
component.validateForm();
});
});
But when i executing the function from spec file am getting this error TypeError: Cannot read property 'trim' of undefined
Import lodash like this
import * as _ from "lodash";
instead of import _ from 'lodash';