Fix AuthInterceptor no expectation tests

- Removed duplicate request
- Added expect().nothing() because httpMock.expectNone will throw an error when a request is made
This commit is contained in:
Alexandre Vryghem
2023-07-16 14:58:22 +02:00
parent b8b9da2525
commit 8d84efb1a9

View File

@@ -20,9 +20,7 @@ describe(`AuthInterceptor`, () => {
const authServiceStub = new AuthServiceStub();
const store: Store<TruncatablesState> = jasmine.createSpyObj('store', {
/* eslint-disable no-empty,@typescript-eslint/no-empty-function */
dispatch: {},
/* eslint-enable no-empty, @typescript-eslint/no-empty-function */
select: observableOf(true)
});
@@ -46,6 +44,10 @@ describe(`AuthInterceptor`, () => {
httpMock = TestBed.inject(HttpTestingController);
});
afterEach(() => {
httpMock.verify();
});
describe('when has a valid token', () => {
it('should not add an Authorization header when were sending a HTTP request to \'authn\' endpoint that is not the logout endpoint', () => {
@@ -95,14 +97,11 @@ describe(`AuthInterceptor`, () => {
});
it('should redirect to login', () => {
service.request(RestRequestMethod.POST, 'dspace-spring-rest/api/submission/workspaceitems', 'password=password&user=user').subscribe((response) => {
expect(response).toBeTruthy();
});
service.request(RestRequestMethod.POST, 'dspace-spring-rest/api/submission/workspaceitems', 'password=password&user=user');
httpMock.expectNone('dspace-spring-rest/api/submission/workspaceitems');
// HttpTestingController.expectNone will throw an error when a requests is made
expect().nothing();
});
});