From: Tiago Melo Date: Thu, 18 Oct 2018 16:49:24 +0000 (+0100) Subject: mgr/dashboard: Update prettier package X-Git-Tag: v14.1.0~989^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bf78a935e19732065c3172a24b57d5f67a6f954e;p=ceph-ci.git mgr/dashboard: Update prettier package Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/package-lock.json b/src/pybind/mgr/dashboard/frontend/package-lock.json index 6d7b8fcf860..80dcc14ea92 100644 --- a/src/pybind/mgr/dashboard/frontend/package-lock.json +++ b/src/pybind/mgr/dashboard/frontend/package-lock.json @@ -8771,9 +8771,9 @@ "dev": true }, "prettier": { - "version": "1.14.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.14.0.tgz", - "integrity": "sha512-KtQ2EGaUwf2EyDfp1fxyEb0PqGKakVm0WyXwDt6u+cAoxbO2Z2CwKvOe3+b4+F2IlO9lYHi1kqFuRM70ddBnow==", + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.14.3.tgz", + "integrity": "sha512-qZDVnCrnpsRJJq5nSsiHCE3BYMED2OtsI+cmzIzF1QIfqm5ALf8tEJcO27zV1gKNKRPdhjO0dNWnrzssDQ1tFg==", "dev": true }, "pretty-error": { diff --git a/src/pybind/mgr/dashboard/frontend/package.json b/src/pybind/mgr/dashboard/frontend/package.json index 3e8a3fed451..7f89063f746 100644 --- a/src/pybind/mgr/dashboard/frontend/package.json +++ b/src/pybind/mgr/dashboard/frontend/package.json @@ -86,7 +86,7 @@ "jest-canvas-mock": "1.1.0", "jest-preset-angular": "6.0.0", "jest-silent-reporter": "0.1.1", - "prettier": "1.14.0", + "prettier": "1.14.3", "protractor": "5.4.0", "ts-node": "7.0.0", "tslint": "5.11.0", diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.spec.ts index 0ce979974c4..c4ce343d4ef 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-purge-modal/rbd-trash-purge-modal.component.spec.ts @@ -40,27 +40,24 @@ describe('RbdTrashPurgeModalComponent', () => { expect(component).toBeTruthy(); }); - it( - 'should finish ngOnInit', - fakeAsync(() => { - component.poolPermission = new Permission(['read', 'create', 'update', 'delete']); - fixture.detectChanges(); - const req = httpTesting.expectOne('api/pool?attrs=pool_name,application_metadata'); - req.flush([ - { - application_metadata: ['foo'], - pool_name: 'bar' - }, - { - application_metadata: ['rbd'], - pool_name: 'baz' - } - ]); - tick(); - expect(component.pools).toEqual(['baz']); - expect(component.purgeForm).toBeTruthy(); - }) - ); + it('should finish ngOnInit', fakeAsync(() => { + component.poolPermission = new Permission(['read', 'create', 'update', 'delete']); + fixture.detectChanges(); + const req = httpTesting.expectOne('api/pool?attrs=pool_name,application_metadata'); + req.flush([ + { + application_metadata: ['foo'], + pool_name: 'bar' + }, + { + application_metadata: ['rbd'], + pool_name: 'baz' + } + ]); + tick(); + expect(component.pools).toEqual(['baz']); + expect(component.purgeForm).toBeTruthy(); + })); it('should call ngOnInit without pool permissions', () => { component.poolPermission = new Permission([]); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts index 71723b5cbc7..dd8ec94d14e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts @@ -125,15 +125,13 @@ describe('OsdListComponent', () => { }); describe('test table actions in submenu', () => { - beforeEach( - fakeAsync(() => { - // The menu needs a click to render the dropdown! - const dropDownToggle = fixture.debugElement.query(By.css('.dropdown-toggle')); - dropDownToggle.triggerEventHandler('click', null); - tick(); - fixture.detectChanges(); - }) - ); + beforeEach(fakeAsync(() => { + // The menu needs a click to render the dropdown! + const dropDownToggle = fixture.debugElement.query(By.css('.dropdown-toggle')); + dropDownToggle.triggerEventHandler('click', null); + tick(); + fixture.detectChanges(); + })); /** * Helper function to retrieve menu item 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 f6025a23e06..6a56c14bbfe 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 @@ -126,22 +126,16 @@ describe('RgwUserFormComponent', () => { formHelper.expectErrorChange('user_id', '', 'required', true); }); - it( - 'should validate that username is valid', - fakeAsync(() => { - formHelper.setValue('user_id', 'ab', true); - tick(500); - formHelper.expectValid('user_id'); - }) - ); - - it( - 'should validate that username is invalid', - fakeAsync(() => { - formHelper.setValue('user_id', 'abc', true); - tick(500); - formHelper.expectError('user_id', 'notUnique'); - }) - ); + it('should validate that username is valid', fakeAsync(() => { + formHelper.setValue('user_id', 'ab', true); + tick(500); + formHelper.expectValid('user_id'); + })); + + it('should validate that username is invalid', fakeAsync(() => { + formHelper.setValue('user_id', 'abc', true); + tick(500); + formHelper.expectError('user_id', 'notUnique'); + })); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.spec.ts index 9b7dac3f1b3..bfc86a7766c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/breadcrumbs/breadcrumbs.component.spec.ts @@ -64,69 +64,54 @@ describe('BreadcrumbsComponent', () => { expect(component.subscription).toBeDefined(); }); - it( - 'should run postProcess and split the breadcrumbs when navigating to hosts', - fakeAsync(() => { - router.navigateByUrl('/hosts'); - tick(); - expect(component.crumbs).toEqual([ - { path: null, text: 'Cluster' }, - { path: '/hosts', text: 'Hosts' } - ]); - }) - ); + it('should run postProcess and split the breadcrumbs when navigating to hosts', fakeAsync(() => { + router.navigateByUrl('/hosts'); + tick(); + expect(component.crumbs).toEqual([ + { path: null, text: 'Cluster' }, + { path: '/hosts', text: 'Hosts' } + ]); + })); - it( - 'should display empty breadcrumb when navigating to perf_counters from unknown path', - fakeAsync(() => { - router.navigateByUrl('/perf_counters'); - tick(); - expect(component.crumbs).toEqual([ - { path: null, text: 'Cluster' }, - { path: null, text: '' }, - { path: '', text: 'Performance Counters' } - ]); - }) - ); + it('should display empty breadcrumb when navigating to perf_counters from unknown path', fakeAsync(() => { + router.navigateByUrl('/perf_counters'); + tick(); + expect(component.crumbs).toEqual([ + { path: null, text: 'Cluster' }, + { path: null, text: '' }, + { path: '', text: 'Performance Counters' } + ]); + })); - it( - 'should display Monitor breadcrumb when navigating to perf_counters from Monitors', - fakeAsync(() => { - router.navigate(['/perf_counters'], { queryParams: { fromLink: '/monitor' } }); - tick(); - expect(component.crumbs).toEqual([ - { path: null, text: 'Cluster' }, - { path: '/monitor', text: 'Monitors' }, - { path: '', text: 'Performance Counters' } - ]); - }) - ); + it('should display Monitor breadcrumb when navigating to perf_counters from Monitors', fakeAsync(() => { + router.navigate(['/perf_counters'], { queryParams: { fromLink: '/monitor' } }); + tick(); + expect(component.crumbs).toEqual([ + { path: null, text: 'Cluster' }, + { path: '/monitor', text: 'Monitors' }, + { path: '', text: 'Performance Counters' } + ]); + })); - it( - 'should display Hosts breadcrumb when navigating to perf_counters from Hosts', - fakeAsync(() => { - router.navigate(['/perf_counters'], { queryParams: { fromLink: '/hosts' } }); - tick(); - expect(component.crumbs).toEqual([ - { path: null, text: 'Cluster' }, - { path: '/hosts', text: 'Hosts' }, - { path: '', text: 'Performance Counters' } - ]); - }) - ); + it('should display Hosts breadcrumb when navigating to perf_counters from Hosts', fakeAsync(() => { + router.navigate(['/perf_counters'], { queryParams: { fromLink: '/hosts' } }); + tick(); + expect(component.crumbs).toEqual([ + { path: null, text: 'Cluster' }, + { path: '/hosts', text: 'Hosts' }, + { path: '', text: 'Performance Counters' } + ]); + })); - it( - 'should show all 3 breadcrumbs when navigating to RBD Add', - fakeAsync(() => { - router.navigateByUrl('/block/rbd/add'); - tick(); - expect(component.crumbs).toEqual([ - { path: null, text: 'Block' }, - { path: '/block/rbd', text: 'Images' }, - { path: '/block/rbd/add', text: 'Add' } - ]); - }) - ); + it('should show all 3 breadcrumbs when navigating to RBD Add', fakeAsync(() => { + router.navigateByUrl('/block/rbd/add'); + tick(); + expect(component.crumbs).toEqual([ + { path: null, text: 'Block' }, + { path: '/block/rbd', text: 'Images' }, + { path: '/block/rbd/add', text: 'Add' } + ]); + })); it('should unsubscribe on ngOnDestroy', () => { expect(component.subscription.closed).toBeFalsy(); 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 fd2d9d8f57b..6c0ecefeb8d 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 @@ -28,31 +28,25 @@ describe('AuthService', () => { expect(service).toBeTruthy(); }); - it( - 'should login and save the user', - fakeAsync(() => { - const fakeCredentials = { username: 'foo', password: 'bar' }; - const fakeResponse = { username: 'foo', token: 'tokenbytes' }; - service.login(fakeCredentials); - const req = httpTesting.expectOne('api/auth'); - expect(req.request.method).toBe('POST'); - expect(req.request.body).toEqual(fakeCredentials); - req.flush(fakeResponse); - tick(); - expect(localStorage.getItem('dashboard_username')).toBe('foo'); - expect(localStorage.getItem('access_token')).toBe('tokenbytes'); - }) - ); - - it( - 'should logout and remove the user', - fakeAsync(() => { - service.logout(); - const req = httpTesting.expectOne('api/auth'); - expect(req.request.method).toBe('DELETE'); - req.flush({ username: 'foo' }); - tick(); - expect(localStorage.getItem('dashboard_username')).toBe(null); - }) - ); + it('should login and save the user', fakeAsync(() => { + const fakeCredentials = { username: 'foo', password: 'bar' }; + const fakeResponse = { username: 'foo', token: 'tokenbytes' }; + service.login(fakeCredentials); + const req = httpTesting.expectOne('api/auth'); + expect(req.request.method).toBe('POST'); + expect(req.request.body).toEqual(fakeCredentials); + req.flush(fakeResponse); + tick(); + expect(localStorage.getItem('dashboard_username')).toBe('foo'); + expect(localStorage.getItem('access_token')).toBe('tokenbytes'); + })); + + it('should logout and remove the user', fakeAsync(() => { + service.logout(); + const req = httpTesting.expectOne('api/auth'); + expect(req.request.method).toBe('DELETE'); + req.flush({ username: 'foo' }); + tick(); + expect(localStorage.getItem('dashboard_username')).toBe(null); + })); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.spec.ts index d283ef7c0fe..a9354ce54f7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.spec.ts @@ -26,16 +26,13 @@ describe('HostService', () => { expect(service).toBeTruthy(); }); - it( - 'should call list', - fakeAsync(() => { - let result; - service.list().then((resp) => (result = resp)); - const req = httpTesting.expectOne('api/host'); - expect(req.request.method).toBe('GET'); - req.flush(['foo', 'bar']); - tick(); - expect(result).toEqual(['foo', 'bar']); - }) - ); + it('should call list', fakeAsync(() => { + let result; + service.list().then((resp) => (result = resp)); + const req = httpTesting.expectOne('api/host'); + expect(req.request.method).toBe('GET'); + req.flush(['foo', 'bar']); + tick(); + expect(result).toEqual(['foo', 'bar']); + })); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.spec.ts index afa5abff2cd..e7cf7f1e5a6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.spec.ts @@ -60,29 +60,23 @@ describe('PoolService', () => { expect(req.request.method).toBe('DELETE'); }); - it( - 'should call list without parameter', - fakeAsync(() => { - let result; - service.list().then((resp) => (result = resp)); - const req = httpTesting.expectOne(`${apiPath}?attrs=`); - expect(req.request.method).toBe('GET'); - req.flush(['foo', 'bar']); - tick(); - expect(result).toEqual(['foo', 'bar']); - }) - ); + it('should call list without parameter', fakeAsync(() => { + let result; + service.list().then((resp) => (result = resp)); + const req = httpTesting.expectOne(`${apiPath}?attrs=`); + expect(req.request.method).toBe('GET'); + req.flush(['foo', 'bar']); + tick(); + expect(result).toEqual(['foo', 'bar']); + })); - it( - 'should call list with a list', - fakeAsync(() => { - let result; - service.list(['foo']).then((resp) => (result = resp)); - const req = httpTesting.expectOne(`${apiPath}?attrs=foo`); - expect(req.request.method).toBe('GET'); - req.flush(['foo', 'bar']); - tick(); - expect(result).toEqual(['foo', 'bar']); - }) - ); + it('should call list with a list', fakeAsync(() => { + let result; + service.list(['foo']).then((resp) => (result = resp)); + const req = httpTesting.expectOne(`${apiPath}?attrs=foo`); + expect(req.request.method).toBe('GET'); + req.flush(['foo', 'bar']); + tick(); + expect(result).toEqual(['foo', 'bar']); + })); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/tcmu-iscsi.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/tcmu-iscsi.service.spec.ts index 2792a801073..99cd424215d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/tcmu-iscsi.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/tcmu-iscsi.service.spec.ts @@ -26,18 +26,15 @@ describe('TcmuIscsiService', () => { expect(service).toBeTruthy(); }); - it( - 'should call tcmuiscsi', - fakeAsync(() => { - let result; - service.tcmuiscsi().subscribe((resp) => { - result = resp; - }); - const req = httpTesting.expectOne('api/tcmuiscsi'); - expect(req.request.method).toBe('GET'); - req.flush(['foo']); - tick(); - expect(result).toEqual(['foo']); - }) - ); + it('should call tcmuiscsi', fakeAsync(() => { + let result; + service.tcmuiscsi().subscribe((resp) => { + result = resp; + }); + const req = httpTesting.expectOne('api/tcmuiscsi'); + expect(req.request.method).toBe('GET'); + req.flush(['foo']); + tick(); + expect(result).toEqual(['foo']); + })); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.spec.ts index f0e54cd4c06..fdc5428921d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.spec.ts @@ -435,22 +435,16 @@ describe('CdValidators', () => { expectValid(''); }); - it( - 'should not error because of not existing input', - fakeAsync(() => { - formHelper.setValue('x', 'abc', true); - tick(500); - formHelper.expectValid('x'); - }) - ); - - it( - 'should error because of already existing input', - fakeAsync(() => { - formHelper.setValue('x', 'xyz', true); - tick(500); - formHelper.expectError('x', 'notUnique'); - }) - ); + it('should not error because of not existing input', fakeAsync(() => { + formHelper.setValue('x', 'abc', true); + tick(500); + formHelper.expectValid('x'); + })); + + it('should error because of already existing input', fakeAsync(() => { + formHelper.setValue('x', 'xyz', true); + tick(500); + formHelper.expectError('x', 'notUnique'); + })); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-guard.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-guard.service.spec.ts index b876228df22..ff101219112 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-guard.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/auth-guard.service.spec.ts @@ -36,13 +36,10 @@ describe('AuthGuardService', () => { expect(service.canActivate(null, null)).toBe(true); }); - it( - 'should prevent user if not loggedIn and redirect to login page', - fakeAsync(() => { - const router = TestBed.get(Router); - expect(service.canActivate(null, null)).toBe(false); - tick(); - expect(router.url).toBe('/login'); - }) - ); + it('should prevent user if not loggedIn and redirect to login page', fakeAsync(() => { + const router = TestBed.get(Router); + expect(service.canActivate(null, null)).toBe(false); + tick(); + expect(router.url).toBe('/login'); + })); }); 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 c6fc4f84abc..a4d5eb8f411 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 @@ -62,25 +62,16 @@ describe('ModuleStatusGuardService', () => { expect(service).toBeTruthy(); }); - it( - 'should test canActivate with status available', - fakeAsync(() => { - route.data.moduleStatusGuardConfig.redirectTo = 'foo'; - testCanActivate({ available: true, message: 'foo' }, true, '/'); - }) - ); + it('should test canActivate with status available', fakeAsync(() => { + route.data.moduleStatusGuardConfig.redirectTo = 'foo'; + testCanActivate({ available: true, message: 'foo' }, true, '/'); + })); - it( - 'should test canActivateChild with status unavailable', - fakeAsync(() => { - testCanActivate({ available: false, message: null }, false, '/foo/'); - }) - ); + it('should test canActivateChild with status unavailable', fakeAsync(() => { + testCanActivate({ available: false, message: null }, false, '/foo/'); + })); - it( - 'should test canActivateChild with status unavailable', - fakeAsync(() => { - testCanActivate(null, false, '/foo'); - }) - ); + it('should test canActivateChild with status unavailable', fakeAsync(() => { + testCanActivate(null, false, '/foo'); + })); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts index 204a9e1c537..56a2bad89f6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.spec.ts @@ -39,110 +39,86 @@ describe('NotificationService', () => { expect(notificationService['dataSource'].getValue()).toEqual([]); }); - it( - 'should read old notifications', - fakeAsync(() => { - localStorage.setItem( - 'cdNotifications', - '[{"type":2,"message":"foobar","timestamp":"2018-05-24T09:41:32.726Z"}]' - ); - const service = new NotificationService(null, null); - expect(service['dataSource'].getValue().length).toBe(1); - }) - ); + it('should read old notifications', fakeAsync(() => { + localStorage.setItem( + 'cdNotifications', + '[{"type":2,"message":"foobar","timestamp":"2018-05-24T09:41:32.726Z"}]' + ); + const service = new NotificationService(null, null); + expect(service['dataSource'].getValue().length).toBe(1); + })); - it( - 'should cancel a notification', - fakeAsync(() => { - const timeoutId = notificationService.show(NotificationType.error, 'Simple test'); - notificationService.cancel(timeoutId); - tick(5000); - expect(notificationService['dataSource'].getValue().length).toBe(0); - }) - ); + it('should cancel a notification', fakeAsync(() => { + const timeoutId = notificationService.show(NotificationType.error, 'Simple test'); + notificationService.cancel(timeoutId); + tick(5000); + expect(notificationService['dataSource'].getValue().length).toBe(0); + })); - it( - 'should create a success notification and save it', - fakeAsync(() => { - notificationService.show(NotificationType.success, 'Simple test'); - tick(100); - expect(notificationService['dataSource'].getValue().length).toBe(1); - expect(notificationService['dataSource'].getValue()[0].type).toBe(NotificationType.success); - }) - ); + it('should create a success notification and save it', fakeAsync(() => { + notificationService.show(NotificationType.success, 'Simple test'); + tick(100); + expect(notificationService['dataSource'].getValue().length).toBe(1); + expect(notificationService['dataSource'].getValue()[0].type).toBe(NotificationType.success); + })); - it( - 'should create an error notification and save it', - fakeAsync(() => { - notificationService.show(NotificationType.error, 'Simple test'); - tick(100); - expect(notificationService['dataSource'].getValue().length).toBe(1); - expect(notificationService['dataSource'].getValue()[0].type).toBe(NotificationType.error); - }) - ); + it('should create an error notification and save it', fakeAsync(() => { + notificationService.show(NotificationType.error, 'Simple test'); + tick(100); + expect(notificationService['dataSource'].getValue().length).toBe(1); + expect(notificationService['dataSource'].getValue()[0].type).toBe(NotificationType.error); + })); - it( - 'should create an info notification and save it', - fakeAsync(() => { + it('should create an info notification and save it', fakeAsync(() => { + notificationService.show(NotificationType.info, 'Simple test'); + tick(100); + expect(notificationService['dataSource'].getValue().length).toBe(1); + const notification = notificationService['dataSource'].getValue()[0]; + expect(notification.type).toBe(NotificationType.info); + expect(notification.title).toBe('Simple test'); + expect(notification.message).toBe(undefined); + })); + + it('should never have more then 10 notifications', fakeAsync(() => { + for (let index = 0; index < 15; index++) { notificationService.show(NotificationType.info, 'Simple test'); tick(100); - expect(notificationService['dataSource'].getValue().length).toBe(1); - const notification = notificationService['dataSource'].getValue()[0]; - expect(notification.type).toBe(NotificationType.info); - expect(notification.title).toBe('Simple test'); - expect(notification.message).toBe(undefined); - }) - ); - - it( - 'should never have more then 10 notifications', - fakeAsync(() => { - for (let index = 0; index < 15; index++) { - notificationService.show(NotificationType.info, 'Simple test'); - tick(100); - } - expect(notificationService['dataSource'].getValue().length).toBe(10); - }) - ); + } + expect(notificationService['dataSource'].getValue().length).toBe(10); + })); - it( - 'should show a success task notification', - fakeAsync(() => { - const task = _.assign(new FinishedTask(), { - success: true - }); - notificationService.notifyTask(task, true); - tick(100); - expect(notificationService['dataSource'].getValue().length).toBe(1); - const notification = notificationService['dataSource'].getValue()[0]; - expect(notification.type).toBe(NotificationType.success); - expect(notification.title).toBe('Executed unknown task'); - expect(notification.message).toBe(undefined); - }) - ); + it('should show a success task notification', fakeAsync(() => { + const task = _.assign(new FinishedTask(), { + success: true + }); + notificationService.notifyTask(task, true); + tick(100); + expect(notificationService['dataSource'].getValue().length).toBe(1); + const notification = notificationService['dataSource'].getValue()[0]; + expect(notification.type).toBe(NotificationType.success); + expect(notification.title).toBe('Executed unknown task'); + expect(notification.message).toBe(undefined); + })); - it( - 'should show a error task notification', - fakeAsync(() => { - const task = _.assign( - new FinishedTask('rbd/create', { - pool_name: 'somePool', - image_name: 'someImage' - }), - { - success: false, - exception: { - code: 17 - } + it('should show a error task notification', fakeAsync(() => { + const task = _.assign( + new FinishedTask('rbd/create', { + pool_name: 'somePool', + image_name: 'someImage' + }), + { + success: false, + exception: { + code: 17 } - ); - notificationService.notifyTask(task); - tick(100); - expect(notificationService['dataSource'].getValue().length).toBe(1); - const notification = notificationService['dataSource'].getValue()[0]; - expect(notification.type).toBe(NotificationType.error); - expect(notification.title).toBe(`Failed to create RBD 'somePool/someImage'`); - expect(notification.message).toBe(`Name is already used by RBD 'somePool/someImage'.`); - }) - ); + } + ); + notificationService.notifyTask(task); + tick(100); + expect(notificationService['dataSource'].getValue().length).toBe(1); + const notification = notificationService['dataSource'].getValue()[0]; + expect(notification.type).toBe(NotificationType.error); + expect(notification.title).toBe(`Failed to create RBD 'somePool/someImage'`); + expect(notification.message).toBe(`Name is already used by RBD 'somePool/someImage'.`); + })); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts index 4dd03110c13..4fbf3a558bc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts @@ -46,21 +46,18 @@ describe('SummaryService', () => { expect(summaryService).toBeTruthy(); }); - it( - 'should call refresh', - fakeAsync(() => { - authStorageService.set('foobar'); - let result = false; - summaryService.refresh(); - summaryService.subscribe(() => { - result = true; - }); - tick(5000); - spyOn(summaryService, 'refresh').and.callFake(() => true); - tick(5000); - expect(result).toEqual(true); - }) - ); + it('should call refresh', fakeAsync(() => { + authStorageService.set('foobar'); + let result = false; + summaryService.refresh(); + summaryService.subscribe(() => { + result = true; + }); + tick(5000); + spyOn(summaryService, 'refresh').and.callFake(() => true); + tick(5000); + expect(result).toEqual(true); + })); describe('Should test methods after first refresh', () => { beforeEach(() => { 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 7fbddbfdd65..1fab5d39e3c 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 @@ -53,28 +53,22 @@ describe('TaskManagerService', () => { expect(taskManagerService).toBeTruthy(); }); - it( - 'should subscribe and be notified when task is finished', - fakeAsync(() => { - expect(taskManagerService.subscriptions.length).toBe(1); - summaryService.refresh(); - tick(); - expect(called).toEqual(true); - expect(taskManagerService.subscriptions).toEqual([]); - }) - ); + it('should subscribe and be notified when task is finished', fakeAsync(() => { + expect(taskManagerService.subscriptions.length).toBe(1); + summaryService.refresh(); + tick(); + expect(called).toEqual(true); + expect(taskManagerService.subscriptions).toEqual([]); + })); - it( - 'should subscribe and process executing taks', - fakeAsync(() => { - const original_subscriptions = _.cloneDeep(taskManagerService.subscriptions); - _.assign(summary, { - executing_tasks: [{ name: 'foo', metadata: {} }], - finished_tasks: [] - }); - summaryService.refresh(); - tick(); - expect(taskManagerService.subscriptions).toEqual(original_subscriptions); - }) - ); + it('should subscribe and process executing taks', fakeAsync(() => { + const original_subscriptions = _.cloneDeep(taskManagerService.subscriptions); + _.assign(summary, { + executing_tasks: [{ name: 'foo', metadata: {} }], + finished_tasks: [] + }); + summaryService.refresh(); + tick(); + expect(taskManagerService.subscriptions).toEqual(original_subscriptions); + })); }); diff --git a/src/pybind/mgr/dashboard/frontend/tslint.json b/src/pybind/mgr/dashboard/frontend/tslint.json index 2163bd977ef..e4c09adcb81 100644 --- a/src/pybind/mgr/dashboard/frontend/tslint.json +++ b/src/pybind/mgr/dashboard/frontend/tslint.json @@ -14,7 +14,6 @@ "indent": [true, "spaces"], "interface-over-type-literal": true, "label-position": true, - "max-line-length": [true, { "limit": 100, "ignore-pattern": "^import |^export {(.*?)}" }], "member-access": false, "member-ordering": [ true,