Skip to content

Commit

Permalink
Fix mock.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerivec committed Jun 15, 2024
1 parent dde550e commit e022902
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/availability.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ describe('Availability', () => {
const availability = controller.extensions.find((extension) => extension instanceof Availability);
const publishAvailabilitySpy = jest.spyOn(availability, 'publishAvailability');

devices.bulb_color.ping = jest.fn().mockImplementation(() => new Promise((resolve) => setTimeout(resolve, 1000)));
devices.bulb_color.ping.mockImplementationOnce(() => new Promise((resolve) => setTimeout(resolve, 1000)));
availability.addToPingQueue(devices.bulb_color);
availability.addToPingQueue(devices.bulb_color_2);

Expand All @@ -358,6 +358,7 @@ describe('Availability', () => {
expect(availability.pingQueue).toEqual([]);
// Validate the stop-interrupt implicitly by checking that it prevents further function invocations
expect(publishAvailabilitySpy).not.toHaveBeenCalled();
devices.bulb_color.ping = jest.fn();// ensure reset
});

it('Should prevent instance restart', async () => {
Expand Down

0 comments on commit e022902

Please sign in to comment.