const verifyPassword = (input, rules) => {
const dayOfWeek = dependencies.moment().day();
if ([SATURDAY, SUNDAY].includes(dayOfWeek)) {
throw Error("It's the weekend!");
}
// 이곳에 다른 코드를 작성한다.
// 발견한 오류를 반환한다.
return [];
};
module.exports = {
SATURDAY,
verifyPassword,
inject
};
➊ moment 모듈을 중간 객체로 감싼다.
➋ 실제 의존성과 가짜 의존성을 담는 객체다.
➌ 실제 의존성에 가짜 의존성을 추가하는 함수(중복은 가짜 의존성으로 대체)다.
➍ 의존성을 원래의 실제 의존성으로 되돌리는 함수다.