]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / auth.service.spec.ts
index 58e44a0e4cb49ea857b822ff75490a8cbc2778b2..c32f0ea05fc9638ff060dbae35b4621ce386ebca 100644 (file)
@@ -1,9 +1,9 @@
 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
 import { fakeAsync, TestBed, tick } from '@angular/core/testing';
-import { Routes } from '@angular/router';
+import { Router, Routes } from '@angular/router';
 import { RouterTestingModule } from '@angular/router/testing';
 
-import { configureTestBed } from '../../../testing/unit-test-helper';
+import { configureTestBed } from '~/testing/unit-test-helper';
 import { AuthStorageService } from '../services/auth-storage.service';
 import { AuthService } from './auth.service';
 
@@ -19,8 +19,8 @@ describe('AuthService', () => {
   });
 
   beforeEach(() => {
-    service = TestBed.get(AuthService);
-    httpTesting = TestBed.get(HttpTestingController);
+    service = TestBed.inject(AuthService);
+    httpTesting = TestBed.inject(HttpTestingController);
   });
 
   afterEach(() => {
@@ -43,12 +43,15 @@ describe('AuthService', () => {
     expect(localStorage.getItem('dashboard_username')).toBe('foo');
   }));
 
-  it('should logout and remove the user', fakeAsync(() => {
+  it('should logout and remove the user', () => {
+    const router = TestBed.inject(Router);
+    spyOn(router, 'navigate').and.stub();
+
     service.logout();
     const req = httpTesting.expectOne('api/auth/logout');
     expect(req.request.method).toBe('POST');
     req.flush({ redirect_url: '#/login' });
-    tick();
     expect(localStorage.getItem('dashboard_username')).toBe(null);
-  }));
+    expect(router.navigate).toBeCalledTimes(1);
+  });
 });