title: Mocking the condition inside code using Jest unit test
body: <p>I'm trying to create a unit test using Jest.
  I have a function that checks the version of the requirement set of Outlook and if the 'set' is supported it does something - in this case, it is closing the add-in.</p>
  <pre><code>if (Office.context.requirements.isSetSupported('Mailbox', '1.15') {...}
  </code></pre>
  <p>In the unit test, I tried to mock the external <em>isSetSupported()</em> call values but when running the <em>getCloseAddin()</em> I am getting an error of:</p>
  <blockquote>
  <p>Office.context.requirements.isSetSupported is not a function</p>
  </blockquote>
  <p>It doesn't recognize the mock function I've just created.
  I've also tried to change the values of the <em>global.Office</em></p>
  <pre><code>global.Office = {
  context: {
    requirements: {
     isSetSupported: {'Mailbox', '1.5'}
    }
  }
  </code></pre>
  <p>};
  but without success.</p>
  <p>file.js</p>
  <pre><code>const getCloseAddin = () =&gt; {
    try {
      const Office = getOffice();
      if (Office.context.requirements.isSetSupported('Mailbox', '1.15')) {
      return Office.context.ui.closeContainer();
    }
  } catch (e) {
    console.error('Cannot close the add-in properly.');
    return null;
   }
  </code></pre>
  <p>};</p>
  <p>file.test.js</p>
  <pre><code>it('verify we gets Undefined when working with supported version', async () =&gt; {
    const mockedIsSetSupported = jest.fn();
    mockedIsSetSupported.mockReturnValueOnce('Mailbox', '1.5');
    global.Office = {
      context: {
        requirements: {
          mockedIsSetSupported
        }
      }
    };
    const closeAddin = await getCloseAddin();
    expect(closeAddin).toBeUndefined();
  });
  </code></pre>