From: Stephan Müller Date: Wed, 8 Jan 2020 17:05:05 +0000 (+0100) Subject: mgr/dashboard: Remove date mock in CephFS directories spec X-Git-Tag: v15.1.1~322^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=514382a3878eecf2fb9ecfc1092b3f518db96a3c;p=ceph.git mgr/dashboard: Remove date mock in CephFS directories spec Fixes: https://tracker.ceph.com/issues/42617 Signed-off-by: Stephan Müller --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.spec.ts index 92d583b24f4..894cfa08ba7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-directories/cephfs-directories.component.spec.ts @@ -42,7 +42,6 @@ describe('CephfsDirectoriesComponent', () => { let maxValidator: jasmine.Spy; let minBinaryValidator: jasmine.Spy; let maxBinaryValidator: jasmine.Spy; - let originalDate: any; let modal: any; // Get's private attributes or functions @@ -67,12 +66,11 @@ describe('CephfsDirectoriesComponent', () => { snapshots: (dirPath: string, howMany: number): CephfsSnapshot[] => { const name = 'someSnapshot'; const snapshots = []; + const oneDay = 3600 * 24 * 1000; for (let i = 0; i < howMany; i++) { const snapName = `${name}${i + 1}`; const path = `${dirPath}/.snap/${snapName}`; - const created = new Date( - +new Date() - 3600 * 24 * 1000 * howMany * (howMany - i) - ).toString(); + const created = new Date(+new Date() - oneDay * i).toString(); snapshots.push({ name: snapName, path, created }); } return snapshots; @@ -147,7 +145,6 @@ describe('CephfsDirectoriesComponent', () => { modal = modalServiceShow(comp, init); return modal.ref; }, - date: (arg: string) => (arg ? new originalDate(arg) : new Date('2022-02-22T00:00:00')), getControllerByPath: (path: string) => { return { expand: () => mockLib.expand(path), @@ -357,8 +354,6 @@ describe('CephfsDirectoriesComponent', () => { deletedSnaps: [], updatedQuotas: {} }; - originalDate = Date; - spyOn(global, 'Date').and.callFake(mockLib.date); cephfsService = TestBed.get(CephfsService); lsDirSpy = spyOn(cephfsService, 'lsDir').and.callFake(mockLib.lsDir);