예제 3-3 currentDay 매개변수를 추가한 verifyPassword() 함수
// stub-time/00-parameteres/password-verifier-time00.js
const verifyPassword2 = (input, rules, currentDay) => {
if ([SATURDAY, SUNDAY].includes(currentDay)) {
throw Error("It's the weekend!");
}
// 이곳에 다른 코드를 작성한다.
// 발견한 오류를 반환한다.
return [];
};
const SUNDAY = 0, SATURDAY = 6, MONDAY = 1;
// stub-time/00-parameteres/password-verifier-time00.spec.js
describe('verifier2 - dummy object', () => {
test('on weekends, throws exceptions', () => {
expect(() => verifyPassword2('anything', [], SUNDAY))
.toThrow("It's the weekend!");
});
});