Skip to content

Commit 8d84efb

Browse files
Fix AuthInterceptor no expectation tests
- Removed duplicate request - Added expect().nothing() because httpMock.expectNone will throw an error when a request is made
1 parent b8b9da2 commit 8d84efb

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

src/app/core/auth/auth.interceptor.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ describe(`AuthInterceptor`, () => {
2020

2121
const authServiceStub = new AuthServiceStub();
2222
const store: Store<TruncatablesState> = jasmine.createSpyObj('store', {
23-
/* eslint-disable no-empty,@typescript-eslint/no-empty-function */
2423
dispatch: {},
25-
/* eslint-enable no-empty, @typescript-eslint/no-empty-function */
2624
select: observableOf(true)
2725
});
2826

@@ -46,6 +44,10 @@ describe(`AuthInterceptor`, () => {
4644
httpMock = TestBed.inject(HttpTestingController);
4745
});
4846

47+
afterEach(() => {
48+
httpMock.verify();
49+
});
50+
4951
describe('when has a valid token', () => {
5052

5153
it('should not add an Authorization header when we’re sending a HTTP request to \'authn\' endpoint that is not the logout endpoint', () => {
@@ -95,14 +97,11 @@ describe(`AuthInterceptor`, () => {
9597
});
9698

9799
it('should redirect to login', () => {
98-
99-
service.request(RestRequestMethod.POST, 'dspace-spring-rest/api/submission/workspaceitems', 'password=password&user=user').subscribe((response) => {
100-
expect(response).toBeTruthy();
101-
});
102-
103100
service.request(RestRequestMethod.POST, 'dspace-spring-rest/api/submission/workspaceitems', 'password=password&user=user');
104101

105102
httpMock.expectNone('dspace-spring-rest/api/submission/workspaceitems');
103+
// HttpTestingController.expectNone will throw an error when a requests is made
104+
expect().nothing();
106105
});
107106
});
108107

0 commit comments

Comments
 (0)