test: Avoid unnecessary nesting.

This commit is contained in:
Ruben Verborgh 2020-12-22 00:08:02 +01:00
parent e4c4d2a781
commit 9a89766858
6 changed files with 434 additions and 445 deletions

View File

@ -12,10 +12,11 @@ module.exports = {
'no-process-env': 'off',
// We are not using Mocha
'mocha/no-nested-tests': 'off',
'mocha/no-exports': 'off',
'mocha/no-nested-tests': 'off',
'mocha/no-skipped-tests': 'off',
'mocha/no-synchronous-tests': 'off',
'mocha/no-top-level-hooks': 'off',
// Need these 2 to run tests for throwing non-Error objects
'@typescript-eslint/no-throw-literal': 'off',

View File

@ -19,7 +19,6 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
) as HttpHandler;
});
describe('with simple handlers', (): void => {
it('can add, read and delete data based on incoming requests.', async(): Promise<void> => {
// POST
let requestUrl = new URL('http://test.com/');
@ -66,9 +65,7 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
expect(response.statusCode).toBe(404);
expect(response._getData()).toContain('NotFoundHttpError');
});
});
describe('with simple PATCH handlers', (): void => {
it('can handle simple SPARQL updates.', async(): Promise<void> => {
// POST
let requestUrl = new URL('http://test.com/');
@ -129,9 +126,7 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
),
]);
});
});
describe('with simple PUT handlers', (): void => {
it('should overwrite the content on PUT request.', async(): Promise<void> => {
// POST
let requestUrl = new URL('http://test.com/');
@ -184,4 +179,3 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
]);
});
});
});

View File

@ -26,8 +26,7 @@ const stores: [string, any][] = [
}],
];
describe.each(stores)('A server using %s', (name, { storeUrn, setup, teardown }): void => {
describe('with acl', (): void => {
describe.each(stores)('An LDP handler with auth using %s', (name, { storeUrn, setup, teardown }): void => {
let handler: HttpHandler;
let aclHelper: AclTestHelper;
let fileHelper: FileTestHelper;
@ -122,4 +121,3 @@ describe.each(stores)('A server using %s', (name, { storeUrn, setup, teardown })
expect(response.statusCode).toBe(401);
});
});
});

View File

@ -23,8 +23,7 @@ const stores: [string, any][] = [
}],
];
describe.each(stores)('A server using %s', (name, { storeUrn, setup, teardown }): void => {
describe('without acl', (): void => {
describe.each(stores)('An LDP handler without auth using %s', (name, { storeUrn, setup, teardown }): void => {
let handler: HttpHandler;
let fileHelper: FileTestHelper;
@ -223,4 +222,3 @@ describe.each(stores)('A server using %s', (name, { storeUrn, setup, teardown })
await fileHelper.shouldNotExist(fileId);
});
});
});

View File

@ -2,8 +2,7 @@ import type { HttpHandler, Initializer, ResourceStore } from '../../src/';
import { describeIf, FileTestHelper } from '../util/TestHelpers';
import { BASE, instantiateFromConfig } from './Config';
describeIf('docker', 'a server with a SPARQL endpoint as storage', (): void => {
describe('without acl', (): void => {
describeIf('docker', 'A server with a SPARQL endpoint as storage', (): void => {
let handler: HttpHandler;
let fileHelper: FileTestHelper;
@ -42,4 +41,3 @@ describeIf('docker', 'a server with a SPARQL endpoint as storage', (): void => {
expect(id).toBeTruthy();
});
});
});