Here is a code snippet for a Helper class:
export class Helper {
static unsubscribeSubscriptions(subscriptions: Subscription[]): void {
subscriptions.forEach(subscription => {
if (subscription) {
subscription.unsubscribe();
}
});
}
static isNullOrEmpty(value: string): boolean {
return (!value || value === undefined || value === '' || value.length === 0);
}
}
I have successfully tested the isNullOrEmpty method, but I am unsure how to test the unsubscribeSubscriptions method. Here is my current testing setup:
describe('Helper', () => {
it('isNullOrEmpty should return true', () => {
// WHEN
const value = '';
const res = Helper.isNullOrEmpty(value);
// THEN
expect(res).toBeTruthy();
});
it('isNullOrEmpty should return false', () => {
// WHEN
const value = 'FULL';
const res = Helper.isNullOrEmpty(value);
// THEN
expect(res).toBeFalsy();
});
});
If anyone has any suggestions on how to test the unsubscribeSubscriptions method, please let me know.