Skip to content

Debugging unit tests with Zod #6549

Answered by MartinM85
MartinM85 asked this question in Q&A
Discussion options

You must be logged in to vote

I've checked how the options are processed when a command is executing and in unit tests of commands that use ZodSchema it' necessary to parse the schema

it('updates working days of signed-in user', async () => {
  const patchStub = sinon.stub(request, 'patch').callsFake(async (opts) => {
    if (opts.url === `https://graph.microsoft.com/v1.0/me/mailboxSettings`) {
      return mailboxSettingsResponse;
    }

    throw 'Invalid request';
  });

  const result = commandOptionsSchema.safeParse({
    workingDays: 'monday,tuesday,wednesday,thursday,friday'
  });

  await command.action(logger, {
    options: result.data
  });

  assert.deepStrictEqual(patchStub.lastCall.args[0].data, {
    wo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MartinM85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant