mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[DURACOM-288] Add unit test to test SSR url replace
This commit is contained in:
@@ -8,7 +8,7 @@ describe('ServerHardRedirectService', () => {
|
||||
const mockRequest = jasmine.createSpyObj(['get']);
|
||||
const mockResponse = jasmine.createSpyObj(['redirect', 'end']);
|
||||
|
||||
const service: ServerHardRedirectService = new ServerHardRedirectService(environment, mockRequest, mockResponse);
|
||||
let service: ServerHardRedirectService = new ServerHardRedirectService(environment, mockRequest, mockResponse);
|
||||
const origin = 'https://test-host.com:4000';
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -69,4 +69,23 @@ describe('ServerHardRedirectService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when SSR base url is set', () => {
|
||||
const redirect = 'https://private-url:4000/server/api/bitstreams/uuid';
|
||||
const replacedUrl = 'https://public-url/server/api/bitstreams/uuid';
|
||||
const environmentWithSSRUrl: any = { ...environment, ...{ ...environment.rest, rest: {
|
||||
ssrBaseUrl: 'https://private-url:4000/server',
|
||||
baseUrl: 'https://public-url/server',
|
||||
} } };
|
||||
service = new ServerHardRedirectService(environmentWithSSRUrl, mockRequest, mockResponse);
|
||||
|
||||
beforeEach(() => {
|
||||
service.redirect(redirect);
|
||||
});
|
||||
|
||||
it('should perform a 302 redirect', () => {
|
||||
expect(mockResponse.redirect).toHaveBeenCalledWith(302, replacedUrl);
|
||||
expect(mockResponse.end).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user