🚨 Fix linting errors

This commit is contained in:
Rune Harlyk
2026-01-02 22:00:25 +01:00
parent 3c557b69a3
commit 21bd4fa837
32 changed files with 438 additions and 245 deletions
+35 -35
View File
@@ -1,46 +1,46 @@
import { describe, it, expect, beforeEach, afterEach, vitest } from 'vitest';
import { throttler } from '../../src/lib/utilities/buffer-utilities';
import { describe, it, expect, beforeEach, afterEach, vitest } from 'vitest'
import { throttler } from '../../src/lib/utilities/buffer-utilities'
describe('throttler', () => {
let throttleInstance: throttler;
let callback: Function;
let throttleInstance: throttler
let callback: () => void
beforeEach(() => {
vitest.useFakeTimers();
throttleInstance = new throttler();
callback = vitest.fn();
});
beforeEach(() => {
vitest.useFakeTimers()
throttleInstance = new throttler()
callback = vitest.fn()
})
afterEach(() => {
vitest.useRealTimers();
});
afterEach(() => {
vitest.useRealTimers()
})
it('should call the callback function after the specified time', () => {
throttleInstance.throttle(callback, 1000);
expect(callback).not.toHaveBeenCalled();
it('should call the callback function after the specified time', () => {
throttleInstance.throttle(callback, 1000)
expect(callback).not.toHaveBeenCalled()
vitest.advanceTimersByTime(1000);
expect(callback).toHaveBeenCalledTimes(1);
});
vitest.advanceTimersByTime(1000)
expect(callback).toHaveBeenCalledTimes(1)
})
it('should not call the callback function if throttle is called again within the timeout period', () => {
throttleInstance.throttle(callback, 1000);
throttleInstance.throttle(callback, 1000);
it('should not call the callback function if throttle is called again within the timeout period', () => {
throttleInstance.throttle(callback, 1000)
throttleInstance.throttle(callback, 1000)
vitest.advanceTimersByTime(500);
expect(callback).not.toHaveBeenCalled();
vitest.advanceTimersByTime(500)
expect(callback).not.toHaveBeenCalled()
vitest.advanceTimersByTime(500);
expect(callback).toHaveBeenCalledTimes(1);
});
vitest.advanceTimersByTime(500)
expect(callback).toHaveBeenCalledTimes(1)
})
it('should allow the callback to be called again after the timeout period', () => {
throttleInstance.throttle(callback, 1000);
vitest.advanceTimersByTime(1000);
expect(callback).toHaveBeenCalledTimes(1);
it('should allow the callback to be called again after the timeout period', () => {
throttleInstance.throttle(callback, 1000)
vitest.advanceTimersByTime(1000)
expect(callback).toHaveBeenCalledTimes(1)
throttleInstance.throttle(callback, 1000);
vitest.advanceTimersByTime(1000);
expect(callback).toHaveBeenCalledTimes(2);
});
});
throttleInstance.throttle(callback, 1000)
vitest.advanceTimersByTime(1000)
expect(callback).toHaveBeenCalledTimes(2)
})
})