Skip to content

Commit

Permalink
test(azure): added test when useContextLogWhenInternalLogger is false
Browse files Browse the repository at this point in the history
  • Loading branch information
H4ad committed Jul 17, 2022
1 parent 9a4d9a7 commit 9664f6b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/handlers/azure.handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,39 @@ describe(AzureHandler.name, () => {
undefined,
);
});

it('should prefer default log method when send false to useContextLogWhenInternalLogger option', () => {
const event = createHttpTriggerEvent('GET', '/');
const context = createHttpTriggerContext('GET', '/');

const defaultServerlessHandler = jest.fn(() => Promise.resolve(response));
const defaultGetHandler = jest
.spyOn(DefaultHandler.prototype, 'getHandler')
.mockImplementation(() => defaultServerlessHandler);

const log = createDefaultLogger();

const getHandlerArguments = [
app,
mockFramework,
adapters,
resolver,
binarySettings,
respondWithErrors,
log,
] as const;

const azureHandler = new AzureHandler({
useContextLogWhenInternalLogger: false,
}).getHandler(...getHandlerArguments);

expect(azureHandler(context, event)).resolves.toBe(response);

expect(defaultGetHandler).toHaveBeenCalledWith(...getHandlerArguments);
expect(defaultServerlessHandler).toHaveBeenCalledWith(
event,
context,
undefined,
);
});
});

0 comments on commit 9664f6b

Please sign in to comment.