Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jest.isolateModules(() => {
// Execute index.js.
require('../');
// Assert.
expect(setContext).toHaveBeenCalled();
const contextCallback = setContext.mock.calls[0][0];
expect(
contextCallback(null, { headers: { foo: 'bar' } })
).toMatchObject({
headers: {
foo: 'bar',
authorization: ''
}
});
// It includes the authorization header if the signin_token is present.
getItem.mockReturnValueOnce('blarg');
expect(contextCallback(null, { headers: {} })).toMatchObject({
headers: {
authorization: 'Bearer blarg'
}
});