🚨 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
+4 -4
View File
@@ -1,11 +1,11 @@
import { expect, test } from '@playwright/test'
test('has title', async ({ page }) => {
await page.goto('/')
await expect(page).toHaveTitle(/Spot micro controller/)
await page.goto('/')
await expect(page).toHaveTitle(/Spot micro controller/)
})
test('index page has expected h1', async ({ page }) => {
await page.goto('/')
await expect(page.getByRole('heading', { name: 'Spot micro controller' }).first()).toBeVisible()
await page.goto('/')
await expect(page.getByRole('heading', { name: 'Spot micro controller' }).first()).toBeVisible()
})
+21 -21
View File
@@ -1,28 +1,28 @@
import { describe, it, expect } from 'vitest';
import { humanFileSize } from '../../src/lib/utilities/string-utilities';
import { describe, it, expect } from 'vitest'
import { humanFileSize } from '../../src/lib/utilities/string-utilities'
describe('humanFileSize', () => {
it('returns "0B" for 0 bytes', () => {
expect(humanFileSize(0)).toBe('0B');
});
it('returns "0B" for 0 bytes', () => {
expect(humanFileSize(0)).toBe('0B')
})
it('returns the size in bytes correctly', () => {
expect(humanFileSize(500)).toBe('500B');
});
it('returns the size in bytes correctly', () => {
expect(humanFileSize(500)).toBe('500B')
})
it('returns the size in kB correctly', () => {
expect(humanFileSize(1024)).toBe('1kB');
});
it('returns the size in kB correctly', () => {
expect(humanFileSize(1024)).toBe('1kB')
})
it('returns the size in MB correctly', () => {
expect(humanFileSize(1048576)).toBe('1MB'); // 1024 * 1024
});
it('returns the size in MB correctly', () => {
expect(humanFileSize(1048576)).toBe('1MB') // 1024 * 1024
})
it('returns the size in GB correctly', () => {
expect(humanFileSize(1073741824)).toBe('1GB'); // 1024 * 1024 * 1024
});
it('returns the size in GB correctly', () => {
expect(humanFileSize(1073741824)).toBe('1GB') // 1024 * 1024 * 1024
})
it('rounds to 2 decimal places correctly', () => {
expect(humanFileSize(1536)).toBe('1.5kB'); // 1024 + 512
});
});
it('rounds to 2 decimal places correctly', () => {
expect(humanFileSize(1536)).toBe('1.5kB') // 1024 + 512
})
})
+34 -34
View File
@@ -1,44 +1,44 @@
import { describe, it, expect } from 'vitest';
import { toUint8, toInt8 } from '../../src/lib/utilities/math-utilities';
import { describe, it, expect } from 'vitest'
import { toUint8, toInt8 } from '../../src/lib/utilities/math-utilities'
describe('toUint8', () => {
it('min interval value should get 0', () => {
expect(toUint8(-1, -1, 1)).toBe(0);
});
it('middle interval value should get 128', () => {
expect(toUint8(0, -1, 1)).toBe(128);
});
it('min interval value should get 0', () => {
expect(toUint8(-1, -1, 1)).toBe(0)
})
it('middle interval value should get 128', () => {
expect(toUint8(0, -1, 1)).toBe(128)
})
it('max interval value should get 255', () => {
expect(toUint8(1, -1, 1)).toBe(255);
});
it('max interval value should get 255', () => {
expect(toUint8(1, -1, 1)).toBe(255)
})
it('min value should be clamped', () => {
expect(toUint8(-2, -1, 1)).toBe(0);
});
it('min value should be clamped', () => {
expect(toUint8(-2, -1, 1)).toBe(0)
})
it('max value should be clamped', () => {
expect(toUint8(2, -1, 1)).toBe(255);
});
});
it('max value should be clamped', () => {
expect(toUint8(2, -1, 1)).toBe(255)
})
})
describe('toInt8', () => {
it('min interval value should get -128', () => {
expect(toInt8(-1, -1, 1)).toBe(-128);
});
it('middle interval value should get 0', () => {
expect(toInt8(0, -1, 1)).toBe(0);
});
it('min interval value should get -128', () => {
expect(toInt8(-1, -1, 1)).toBe(-128)
})
it('middle interval value should get 0', () => {
expect(toInt8(0, -1, 1)).toBe(0)
})
it('max interval value should get 127', () => {
expect(toInt8(1, -1, 1)).toBe(127);
});
it('max interval value should get 127', () => {
expect(toInt8(1, -1, 1)).toBe(127)
})
it('min value should be clamped', () => {
expect(toInt8(-2, -1, 1)).toBe(-128);
});
it('min value should be clamped', () => {
expect(toInt8(-2, -1, 1)).toBe(-128)
})
it('max value should be clamped', () => {
expect(toInt8(2, -1, 1)).toBe(127);
});
});
it('max value should be clamped', () => {
expect(toInt8(2, -1, 1)).toBe(127)
})
})
+31 -31
View File
@@ -1,39 +1,39 @@
import { describe, it, expect } from 'vitest';
import { Result } from '../../src/lib/utilities/result';
import { describe, it, expect } from 'vitest'
import { Result } from '../../src/lib/utilities/result'
describe('Result', () => {
it('should create a success result correctly', () => {
const successValue = 'Success value';
const result = Result.ok(successValue);
it('should create a success result correctly', () => {
const successValue = 'Success value'
const result = Result.ok(successValue)
expect(result.isOk()).toBe(true);
expect(result.isErr()).toBe(false);
expect(result.inner).toBe(successValue);
});
expect(result.isOk()).toBe(true)
expect(result.isErr()).toBe(false)
expect(result.inner).toBe(successValue)
})
it('should create an error result correctly', () => {
const errorMessage = 'Error message';
const result = Result.err(errorMessage);
it('should create an error result correctly', () => {
const errorMessage = 'Error message'
const result = Result.err(errorMessage)
expect(result.isOk()).toBe(false);
expect(result.isErr()).toBe(true);
expect(result.inner).toBe(errorMessage);
});
expect(result.isOk()).toBe(false)
expect(result.isErr()).toBe(true)
expect(result.inner).toBe(errorMessage)
})
it('should type guard success and error results correctly', () => {
const successResult = Result.ok(123);
const errorResult = Result.err('Error');
it('should type guard success and error results correctly', () => {
const successResult = Result.ok(123)
const errorResult = Result.err('Error')
if (successResult.isOk()) {
expect(typeof successResult.inner).toBe('number');
} else {
throw new Error('Expected successResult to be ok');
}
if (successResult.isOk()) {
expect(typeof successResult.inner).toBe('number')
} else {
throw new Error('Expected successResult to be ok')
}
if (errorResult.isErr()) {
expect(typeof errorResult.inner).toBe('string');
} else {
throw new Error('Expected errorResult to be fail');
}
});
});
if (errorResult.isErr()) {
expect(typeof errorResult.inner).toBe('string')
} else {
throw new Error('Expected errorResult to be fail')
}
})
})
+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)
})
})