Вы можете просто просмотреть все случаи, например:
describe('calculate', () => {
it('should return object with result, nextOperand, and operator as null if buttonName is "AC"', () => {
expect(calculate({}, "AC")).toEqual({
result: null,
nextOperand: null,
operator: null
});
});
it('should return empty object if buttonName is "." and object nextOperand contains a "."', () => {
expect(calculate({ nextOperand: ".5" }, ".")).toEqual({});
});
it('should return object with nextOperand appended with a "." if buttonName is "." and object nextOperand does not contain a "."', () => {
expect(calculate({ nextOperand: "60" }, ".")).toEqual({
nextOperand: "60."
});
});
it('should return object with nextOperand as 0." with a "." if buttonName is "." and object nextOperand does not exist', () => {
expect(calculate({}, ".")).toEqual({
nextOperand: "0."
});
});
});