Here is a demonstration of how you can handle all three scenarios:
class ExampleClass {
getValues(values: any) {
if (values) {
return values.number ? 'First' : 'Second';
}
return 'Third';
}
}
describe('getValues', () => {
const subject: ExampleClass = new ExampleClass();
it('when no values are provided', () => {
expect(subject.getValues(null)).toBe('Third');
});
it('values has a number property', () => {
const values = { number: 5 };
expect(subject.getValues(values)).toBe('First');
});
it('values does not have a number property', () => {
const values = {};
expect(subject.getValues(values)).toBe('Second');
});
});
This ExampleClass serves as an illustration for this purpose.