From: Tiago Melo Date: Wed, 13 May 2020 17:47:10 +0000 (+0000) Subject: mgr/dashboard: Remove unit tests warnings X-Git-Tag: v16.1.0~2331^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4ef1e85dcb1d86647d33e30a1019896a370bd596;p=ceph.git mgr/dashboard: Remove unit tests warnings Fixes: https://tracker.ceph.com/issues/45536 Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts index 68dc6303f46b..15a86ac1e670 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-list/rbd-trash-list.component.spec.ts @@ -1,13 +1,14 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { By } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; +import * as moment from 'moment'; import { TabsModule } from 'ngx-bootstrap/tabs'; import { ToastrModule } from 'ngx-toastr'; import { of } from 'rxjs'; -import { By } from '@angular/platform-browser'; import { configureTestBed, expectItemTasks, @@ -119,7 +120,7 @@ describe('RbdTrashListComponent', () => { images.push({ id: id, pool_name: 'pl', - deferment_end_time: 'abc' + deferment_end_time: moment() }); }; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts index 6a2e63d7b419..b88e8d853206 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/auth.service.spec.ts @@ -1,6 +1,6 @@ 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'; @@ -44,12 +44,15 @@ describe('AuthService', () => { expect(localStorage.getItem('access_token')).toBe('tokenbytes'); })); - it('should logout and remove the user', fakeAsync(() => { + it('should logout and remove the user', () => { + const router = TestBed.get(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); + }); });