"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": {
"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",
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([]);
});
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
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');
+ }));
});
});
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();
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(<any>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(<any>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);
+ }));
});
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']);
+ }));
});
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']);
+ }));
});
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']);
+ }));
});
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');
+ }));
});
});
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');
+ }));
});
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');
+ }));
});
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'.`);
+ }));
});
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(() => {
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);
+ }));
});
"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,