From ec51e87348ba2baae681a01d9d5f8dc9922dde0b Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Wed, 4 Jul 2018 17:20:56 +0100 Subject: [PATCH] mgr/dashboard: prettify code Signed-off-by: Tiago Melo --- .../rgw-user-form.component.spec.ts | 42 +++++++------------ .../rgw-user-subuser-modal.component.spec.ts | 9 ++-- .../dashboard-help.component.spec.ts | 1 - .../task-manager.component.spec.ts | 8 ++-- .../datatable/table/table.component.spec.ts | 2 +- .../module-status-guard.service.spec.ts | 13 +++--- .../services/task-manager.service.spec.ts | 9 ++-- 7 files changed, 37 insertions(+), 47 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts index 90f886e22c7..a2609aa0a45 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts @@ -24,17 +24,9 @@ describe('RgwUserFormComponent', () => { } configureTestBed({ - declarations: [ RgwUserFormComponent ], - imports: [ - HttpClientTestingModule, - ReactiveFormsModule, - RouterTestingModule, - SharedModule - ], - providers: [ - BsModalService, - { provide: RgwUserService, useClass: MockRgwUserService } - ] + declarations: [RgwUserFormComponent], + imports: [HttpClientTestingModule, ReactiveFormsModule, RouterTestingModule, SharedModule], + providers: [BsModalService, { provide: RgwUserService, useClass: MockRgwUserService }] }); beforeEach(() => { @@ -67,14 +59,12 @@ describe('RgwUserFormComponent', () => { component.setS3Key(key); expect(component.s3Keys.length).toBe(1); expect(component.s3Keys[0].user).toBe('test1:subuser2'); - expect(rgwUserService.addS3Key).toHaveBeenCalledWith( - 'test1', { - subuser: 'subuser2', - generate_key: 'false', - access_key: undefined, - secret_key: undefined - } - ); + expect(rgwUserService.addS3Key).toHaveBeenCalledWith('test1', { + subuser: 'subuser2', + generate_key: 'false', + access_key: undefined, + secret_key: undefined + }); }); it('should set key w/o subuser', () => { @@ -83,14 +73,12 @@ describe('RgwUserFormComponent', () => { component.setS3Key(key); expect(component.s3Keys.length).toBe(1); expect(component.s3Keys[0].user).toBe('test1'); - expect(rgwUserService.addS3Key).toHaveBeenCalledWith( - 'test1', { - subuser: '', - generate_key: 'false', - access_key: undefined, - secret_key: undefined - } - ); + expect(rgwUserService.addS3Key).toHaveBeenCalledWith('test1', { + subuser: '', + generate_key: 'false', + access_key: undefined, + secret_key: undefined + }); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.spec.ts index f321dfe6595..4c11f6a8f97 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.spec.ts @@ -12,12 +12,9 @@ describe('RgwUserSubuserModalComponent', () => { let fixture: ComponentFixture; configureTestBed({ - declarations: [ RgwUserSubuserModalComponent ], - imports: [ - ReactiveFormsModule, - SharedModule - ], - providers: [ BsModalRef ] + declarations: [RgwUserSubuserModalComponent], + imports: [ReactiveFormsModule, SharedModule], + providers: [BsModalRef] }); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts index 738f89c4ed5..3e18c5490b8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts @@ -23,5 +23,4 @@ describe('DashboardHelpComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); - }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.spec.ts index a7cab79cef1..8b8f4a25cc8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.spec.ts @@ -53,17 +53,17 @@ describe('TaskManagerComponent', () => { it('should get executing message for task', () => { component._handleTasks(tasks.executing, []); expect(component.executingTasks.length).toBe(1); - expect(component.executingTasks[0].description).toBe('Deleting RBD \'somePool/someImage\''); + expect(component.executingTasks[0].description).toBe(`Deleting RBD 'somePool/someImage'`); }); it('should get finished message for task', () => { component._handleTasks([], tasks.finished); expect(component.finishedTasks.length).toBe(2); - expect(component.finishedTasks[0].description).toBe('Copy RBD \'somePool/someImage\''); + expect(component.finishedTasks[0].description).toBe(`Copy RBD 'somePool/someImage'`); expect(component.finishedTasks[0].errorMessage).toBe(undefined); - expect(component.finishedTasks[1].description).toBe('Clone RBD \'somePool/someImage\''); + expect(component.finishedTasks[1].description).toBe(`Clone RBD 'somePool/someImage'`); expect(component.finishedTasks[1].errorMessage).toBe( - 'Name \'somePool/someImage\' is already in use.' + `Name 'somePool/someImage' is already in use.` ); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts index 4dce6a0949e..209bd12300b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.spec.ts @@ -19,7 +19,7 @@ describe('TableComponent', () => { data.push({ a: i, b: i * i, - c: [-(i % 10), 'score' + (i % 16 + 6)], + c: [-(i % 10), 'score' + ((i % 16) + 6)], d: !(i % 2) }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts index a1772305255..c6fc4f84abc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts @@ -36,11 +36,14 @@ describe('ModuleStatusGuardService', () => { expect(router.url).toBe(urlResult); }; - configureTestBed({ - imports: [RouterTestingModule.withRoutes(routes)], - providers: [ModuleStatusGuardService, { provide: HttpClient, useValue: fakeService }], - declarations: [FooComponent] - }, true); + configureTestBed( + { + imports: [RouterTestingModule.withRoutes(routes)], + providers: [ModuleStatusGuardService, { provide: HttpClient, useValue: fakeService }], + declarations: [FooComponent] + }, + true + ); beforeEach(() => { service = TestBed.get(ModuleStatusGuardService); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts index 635dba15375..ad024392f76 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts @@ -27,9 +27,12 @@ describe('TaskManagerService', () => { filesystems: [{ id: 1, name: 'cephfs_a' }] }; - configureTestBed({ - providers: [TaskManagerService, { provide: SummaryService, useValue: fakeService }] - }, true); + configureTestBed( + { + providers: [TaskManagerService, { provide: SummaryService, useValue: fakeService }] + }, + true + ); beforeEach(() => { taskManagerService = TestBed.get(TaskManagerService); -- 2.39.5