How to handle external dependencies like Moment.js in unit tests for stub implementation?

I am currently learning unit testing in JavaScript, particularly focusing on stubs, from “The Art of Unit Testing”. The author talks about making code more testable by removing dependencies, but I’m confused about how to apply this concept when using stubs with external dependencies like moment().

Here’s my situation: I have a password verification function that throws an error if it’s called on a weekend. There is also a wrapper function, verifyPasswordForCurrentDay, which uses moment().day() to get the current day of the week:

const SUNDAY = 0, SATURDAY = 6;

const verifyPassword = (input, rules, currentDay) => {
  if ([SATURDAY, SUNDAY].includes(currentDay)) {
    throw new Error("It's the weekend!");
  }
  // more code here...
  return [];
};

const verifyPasswordForCurrentDay = (input, rules) => {
  const currentDay = moment().day();
  return verifyPassword(input, rules, currentDay);
};

I’ve been able to test the verifyPassword function using a stub, passing the day of the week as a parameter. Here’s the test:

describe("verifier", () => {
  test("on weekends, throws exceptions", () => {
    expect(() => verifyPassword("any input", [], SUNDAY)).toThrow(
      "It's the weekend!"
    );
  });
});

However, I’m having trouble testing verifyPasswordForCurrentDay, as it has a dependency on moment().day(). In The Art of Unit Testing, the author suggests removing dependencies to make code testable.

I’m also concerned that we’ve merely moved the problem up one level. verifyPasswordForCurrentDay still has an external dependency (moment), making it difficult to test. By using parameter injection, we make a testable function (verifyPassword), but we’re only moving the problem up a level, meaning the wrapper function (verifyPasswordForCurrentDay) becomes untestable or harder to test. Is this correct?