mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Full rework of account management
Complete rewrite of the account management and related systems. Makes the architecture more modular, allowing for easier extensions and configurations.
This commit is contained in:
@@ -2,23 +2,34 @@ import type { InteractionRoute } from '../../../../../src/identity/interaction/r
|
||||
import {
|
||||
RelativePathInteractionRoute,
|
||||
} from '../../../../../src/identity/interaction/routing/RelativePathInteractionRoute';
|
||||
import { InternalServerError } from '../../../../../src/util/errors/InternalServerError';
|
||||
|
||||
describe('A RelativePathInteractionRoute', (): void => {
|
||||
const relativePath = '/relative/';
|
||||
let route: jest.Mocked<InteractionRoute>;
|
||||
let relativeRoute: RelativePathInteractionRoute;
|
||||
let route: jest.Mocked<InteractionRoute<'base'>>;
|
||||
let relativeRoute: RelativePathInteractionRoute<'base'>;
|
||||
|
||||
beforeEach(async(): Promise<void> => {
|
||||
route = {
|
||||
getPath: jest.fn().mockReturnValue('http://example.com/'),
|
||||
matchPath: jest.fn().mockReturnValue({ base: 'base' }),
|
||||
};
|
||||
|
||||
relativeRoute = new RelativePathInteractionRoute(route, relativePath);
|
||||
});
|
||||
|
||||
it('returns the joined path.', async(): Promise<void> => {
|
||||
relativeRoute = new RelativePathInteractionRoute(route, relativePath);
|
||||
expect(relativeRoute.getPath()).toBe('http://example.com/relative/');
|
||||
});
|
||||
|
||||
relativeRoute = new RelativePathInteractionRoute('http://example.com/test/', relativePath);
|
||||
expect(relativeRoute.getPath()).toBe('http://example.com/test/relative/');
|
||||
it('matches paths by checking if the tail matches the relative path.', async(): Promise<void> => {
|
||||
expect(relativeRoute.matchPath('http://example.com/relative/')).toEqual({ base: 'base' });
|
||||
|
||||
expect(relativeRoute.matchPath('http://example.com/relative')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('errors if the base path does not end in a slash.', async(): Promise<void> => {
|
||||
route.getPath.mockReturnValueOnce('http://example.com/foo');
|
||||
expect((): string => relativeRoute.getPath()).toThrow(InternalServerError);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user