jwt.interceptor.spec.ts 864 B

123456789101112131415161718192021222324252627282930
  1. import { TestBed } from '@angular/core/testing';
  2. import { JwtInterceptor } from './jwt.interceptor';
  3. import { HttpClientTestingModule } from '@angular/common/http/testing';
  4. import { AuthService } from '../services/auth.service';
  5. import { Router } from '@angular/router';
  6. class MockAuthService {}
  7. class MockRouter {}
  8. describe('JwtInterceptor', () => {
  9. beforeEach(() => {
  10. TestBed.configureTestingModule({
  11. imports: [HttpClientTestingModule],
  12. providers: [
  13. JwtInterceptor,
  14. { provide: AuthService, useClass: MockAuthService },
  15. { provide: Router, useClass: MockRouter },
  16. // ... other providers if needed
  17. ],
  18. });
  19. });
  20. it('should be created', () => {
  21. const interceptor: JwtInterceptor = TestBed.inject(JwtInterceptor);
  22. expect(interceptor).toBeTruthy();
  23. });
  24. // Add more test cases as needed
  25. });