beforeEach(() => { broker = { initProducerId: jest.fn().mockReturnValue(mockInitProducerIdResponse), addPartitionsToTxn: jest.fn(), endTxn: jest.fn(), addOffsetsToTxn: jest.fn(), txnOffsetCommit: jest.fn(), } cluster = { refreshMetadataIfNecessary: jest.fn(), findGroupCoordinator: jest.fn().mockReturnValue(broker), findControllerBroker: jest.fn().mockReturnValue(broker), } })
const sequentially = concurrency({ limit: 1, onChange }) const input = [ [jest.fn().mockReturnValue(1), 50], [jest.fn().mockReturnValue(2), 100], [jest.fn().mockReturnValue(3), 10], [jest.fn().mockReturnValue(4), 10], const concurrently = concurrency({ limit: 2, onChange }) const input = [ [jest.fn().mockReturnValue(1), 50], [jest.fn().mockReturnValue(2), 100], [jest.fn().mockReturnValue(3), 10],
getTransactionalId: jest.fn(() => mockTransactionalId), updateSequence: jest.fn(), isTransactional: jest.fn().mockReturnValue(false), addPartitionsToTransaction: jest.fn(),
describe('basic feature', () => { it('should return the right value', () => { expect(modulo1.func1(10)).toBe(11) }) it('func2', () => { const cb = jest.fn() cb.mockReturnValue(1) expect(modulo1.func2(10, cb)).toBe(11) // Já verificou caso o Mock foi chamado com o valor certo expect(cb.mock.calls[0][0]).toBe(10) // Inspecionar caso a chamada foi com valor correto // console.log(cb.mock.calls) }) })
jest.mock('../utils/misc', () => ({ shouldRecordStubParams: jest.fn().mockReturnValue(true), }));
lower = jest.fn().mockResolvedValue("result"); spier = { track: jest.fn() }; spierFactory = { makeSpier: jest.fn().mockReturnValue(spier) }; input = "event"; lc = { $spierFactory: spierFactory };
}; const set = jest.fn(); const get = jest.fn().mockReturnValue(undefined); cls.getNamespace.mockImplementation(() => ({ set, get })); pre(meta, params); }; const set = jest.fn(); const get = jest.fn().mockReturnValue([oldMeta]); cls.getNamespace.mockImplementation(() => ({ set, get })); pre(meta, params);
lc = { orderRepository: { save: jest.fn().mockReturnValue(Promise.resolve()) }, orderStream: { send: jest.fn().mockReturnValue(Promise.resolve()) }, idGenerator: { generate: jest.fn().mockReturnValue("123") }, apiKey: "secret",
findByRestaurantId: jest .fn() .mockReturnValue([{ total: 5 }, { total: 10 }]) }; restaurantId = 5;
findByRestaurantId: jest .fn() .mockReturnValue([{ total: 5 }, { total: 10 }]) }; restaurantId = 5;
lc = { orderRepository: { save: jest.fn().mockReturnValue(Promise.resolve()) }, orderStream: { send: jest.fn().mockReturnValue(Promise.resolve()) }, idGenerator: { generate: jest.fn().mockReturnValue("123") }, apiKey: "secret",