Во-первых, у вас небольшая ошибка в веселом getCurrentDay c, вам не нужно вычитать 1.
Здесь я написал все необходимые тесты, у вас есть вопросы? Самое главное, что вы должны предоставить постоянные даты для тестов. Не стати c даты могут меняться со временем. (например, вы не должны использовать new Date () без параметра)
function getCurrentMonth(d){
a=d.getMonth()+1;
return (a< 10) ? '0' + a.toString() : a.toString();
}
function getCurrentDay(d){
b=d.getDate();
return (b< 10) ? '0' + b.toString() : b.toString();
}
test('should add 0 before month if contains 1 number', () => {
let d = new Date('2020-01-01T10:10:00Z')
expect(getCurrentMonth(d)).toBe("01");
});
test('should return month', () => {
let d = new Date('2020-10-01T10:10:00Z')
expect(getCurrentMonth(d)).toBe("10");
});
test('should add 0 before day if contains 1 number', () => {
let d = new Date('2020-01-02T10:10:00Z')
expect(getCurrentDay(d)).toBe("02");
});
test('should return day', () => {
let d = new Date('2020-10-21T10:10:00Z')
expect(getCurrentDay(d)).toBe("21");
});