Skip to content

Commit

Permalink
Clean up stray log and setTimeout testing approach
Browse files Browse the repository at this point in the history
  • Loading branch information
marcysutton committed Nov 27, 2024
1 parent e526e3b commit 260b6b1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,9 @@ import {announceMessage} from "../announce-message";
import {clearMessages} from "../clear-messages";

jest.useFakeTimers();

let originalSetTimeout: typeof setTimeout;
jest.spyOn(global, "setTimeout");

describe("Announcer.announceMessage", () => {
beforeAll(() => {
originalSetTimeout = global.setTimeout;

// Mock setTimeout to log its calls
jest.spyOn(global, "setTimeout").mockImplementation(
(callback, delay) => {
console.log("setTimeout called with delay:", delay);
// Call the original setTimeout implementation
return originalSetTimeout(callback, delay);
},
);
});

afterEach(() => {
jest.clearAllMocks(); // Clear mocks after each test
});

afterEach(() => {
clearMessages();
});
Expand Down
1 change: 0 additions & 1 deletion packages/wonder-blocks-announcer/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function alternateIndex(index: number, count: number): number {
* @returns {string} idRef of targeted live region element
*/
export function debounce(callback: (...args: any[]) => string, wait: number) {
console.log("wait:", wait);
let timeoutId: ReturnType<typeof setTimeout> | null = null;
let executed = false;

Expand Down

0 comments on commit 260b6b1

Please sign in to comment.