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/');
@ -183,5 +178,4 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
),
]);
});
});
});

View File

@ -61,7 +61,7 @@ describe('A server with authorization', (): void => {
expect(response.statusCode).toBe(205);
});
it('can not create new entries if not allowed.', async(): Promise<void> => {
it('cannot create new entries if not allowed.', async(): Promise<void> => {
await aclHelper.setSimpleAcl({ read: true, write: true, append: true }, 'authenticated');
// POST

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;
@ -121,5 +120,4 @@ describe.each(stores)('A server using %s', (name, { storeUrn, setup, teardown })
response = await fileHelper.deleteResource('http://test.com/permanent.txt', true);
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;
@ -222,5 +221,4 @@ describe.each(stores)('A server using %s', (name, { storeUrn, setup, teardown })
await fileHelper.deleteResource(fileId);
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;
@ -41,5 +40,4 @@ describeIf('docker', 'a server with a SPARQL endpoint as storage', (): void => {
const id = response._getHeaders().location;
expect(id).toBeTruthy();
});
});
});