mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
refactor: Enable stricter test linting
This commit is contained in:
@@ -249,7 +249,7 @@ describe('PathUtil', (): void => {
|
||||
// Note that this test only makes sense as long as the dist folder is on the same level as the src folder
|
||||
const root = getModuleRoot();
|
||||
const packageJson = joinFilePath(root, 'package.json');
|
||||
expect(await fsPromises.access(packageJson)).toBeUndefined();
|
||||
await expect(fsPromises.access(packageJson)).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('HandlerUtil', (): void => {
|
||||
});
|
||||
|
||||
it('supports non-native Errors.', async(): Promise<void> => {
|
||||
handlerFalse.canHandle = jest.fn().mockRejectedValue('apple');
|
||||
jest.spyOn(handlerFalse, 'canHandle').mockRejectedValue('apple');
|
||||
await expect(findHandler([ handlerFalse ], null)).rejects.toThrow('Unknown error: apple');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -125,7 +125,7 @@ describe('A FileSystemResourceLocker', (): void => {
|
||||
it('stops proper-lock from throwing errors after finalize was called.', async(): Promise<void> => {
|
||||
// Tests should never access private fields so we need to change this after splitting the test as mentioned above.
|
||||
// Once we have a mock we can check which parameters `unlock` was called with and extract the function from there.
|
||||
expect((): void => (locker as any).customOnCompromised(new Error('test'))).toThrow();
|
||||
expect((): void => (locker as any).customOnCompromised(new Error('test'))).toThrow('test');
|
||||
await locker.finalize();
|
||||
expect((locker as any).customOnCompromised(new Error('test'))).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('A GreedyReadWriteLocker', (): void => {
|
||||
});
|
||||
|
||||
it('errors if the read counter has an unexpected value.', async(): Promise<void> => {
|
||||
storage.get = jest.fn().mockResolvedValue(0);
|
||||
jest.spyOn(storage, 'get').mockResolvedValue(0);
|
||||
await expect(locker.withReadLock(resourceId, (): number => 5)).rejects.toThrow(InternalServerError);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user