Trying to test the following function to make sure it gets called and if its working properly Here is the function :
sanitizeEmail = (email) => {
let result = email;
if(result.indexOf('@') !== -1 && result.substring(0,result.indexOf('@')).length > 3 ) {
let end = result.indexOf('@');
let temp = '';
for(let i in result.substring(4,end)) {
temp = temp + '*';
}
result = result.substring(0,3) + temp + result.substring(end, result.length);
}
return result
}
Using Jest and Enzyme for React Js
Here my test at the moment
beforeEach(() => wrapper = mount(<MemoryRouter keyLength={0}><ProfileMenuComponent {...baseProps} /></MemoryRouter>));
it('Test componentDidMount method',() => {
wrapper.setProps({
user:{
Email:""
}
})
wrapper.find('ProfileMenuComponent').setState({
permissionsLoaded:true,
localPermissions:{[globals.UI_NOTIFICATION ]:true }
});
wrapper.update();
Not really sure how to work around with the 2 statements below:
expect(wrapper.find('ProfileMenuComponent').instance().componentDidMount()).toEqual();
expect(wrapper.find('ProfileMenuComponent').state('permissionsLoaded')).toBeTruthy();
});
Aucun commentaire:
Enregistrer un commentaire