My background with unit testing is minimal.
From what I've found on Google it appears that I would have to change a lot of the code in our application in order to unit test arrow function code.
So, if code were as follow
class MyComponent {
fun: () => 'hello';
constructor() {};
}
Then I must change it to something like the following in order to unit test it.
Create an interface
Interface MyService {
fun: () => string;
}
And change the code,
class Component {
constructor() {
this.mysService = () => {
return {
fun: () => 'hello'
};
};
}
myService: () => MyService;
}
I don't think you need to change anything in your code in order to test your arrow functions:
Assuming you have this component with the
myFunc
arrow function:in your spec file, you can do the following: