Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ describe('SiDashboardToolbarComponent', () => {
});

it('#onEdit() shall set editable mode', async () => {
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);
const button = fixture.debugElement.query(By.css('button'));
button.triggerEventHandler('click', null);
await fixture.whenStable();
fixture.detectChanges();

expect(component.editable()).toBeTrue();
expect(component.editable()).toBe(true);
const buttons = fixture.debugElement.queryAll(By.css('button'));
expect(buttons.length).toBe(2);
});
Expand All @@ -51,7 +51,7 @@ describe('SiDashboardToolbarComponent', () => {
await fixture.whenStable();
fixture.detectChanges();

expect(component.editable()).withContext('Cancel shall not change editable state').toBeTrue();
expect(component.editable()).withContext('Cancel shall not change editable state').toBe(true);
});

it('#onSave() shall cancel editable mode and emit save', async () => {
Expand All @@ -65,11 +65,11 @@ describe('SiDashboardToolbarComponent', () => {
await fixture.whenStable();
fixture.detectChanges();

expect(component.editable()).withContext('Save shall not change editable state').toBeTrue();
expect(component.editable()).withContext('Save shall not change editable state').toBe(true);
});

it('#hideEditButton shall hide the edit button', () => {
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);
let editButton = fixture.debugElement.query(By.css('.element-edit'));
expect(editButton).not.toBeNull();
expect(editButton).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,16 @@ describe('SiFlexibleDashboardComponent', () => {

it('should call #grid.edit() on changing editable input to true', () => {
const spy = spyOn(grid, 'edit').and.callThrough();
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);
fixture.componentRef.setInput('editable', true);
component.ngOnChanges({ editable: new SimpleChange(false, true, true) });
expect(spy).toHaveBeenCalled();
});

it('should call #grid.cancel() on changing editable input to false', () => {
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);
grid.editable.set(true);
expect(component.editable()).toBeTrue();
expect(component.editable()).toBe(true);
const spy = spyOn(grid, 'cancel').and.callThrough();

fixture.componentRef.setInput('editable', false);
Expand All @@ -217,7 +217,7 @@ describe('SiFlexibleDashboardComponent', () => {

it('should emit editableChange events on changing grid editable state', () => {
grid.editable.set(true);
expect(component.editable()).toBeTrue();
expect(component.editable()).toBe(true);
});

it('should restore the dashboard on dashboardId changes when dashboard is expanded', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,51 +74,51 @@ describe('SiGridComponent', () => {
});

it('#edit() should change editable state to true', () => {
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);
component.edit();
expect(component.editable()).toBeTrue();
expect(component.editable()).toBe(true);
});

it('#cancel() should change editable state to false', () => {
fixture.componentRef.setInput('editable', true);
fixture.detectChanges();
expect(component.editable()).toBeTrue();
expect(component.editable()).toBe(true);
component.cancel();
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);
});

describe('#save()', () => {
it('should change editable state to false', async () => {
fixture.componentRef.setInput('editable', true);
fixture.detectChanges();
expect(component.editable()).toBeTrue();
expect(component.editable()).toBe(true);
const spy = spyOn(widgetStorage, 'save').and.callThrough();
component.save();
expect(spy).toHaveBeenCalled();
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);
});
});

it('should call edit() on setting editable to true', () => {
const spy = spyOn(component, 'edit').and.callThrough();
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);

fixture.componentRef.setInput('editable', true);
component.ngOnChanges({ editable: new SimpleChange(false, true, false) });
expect(spy).toHaveBeenCalled();
expect(component.editable()).toBeTrue();
expect(component.editable()).toBe(true);
});

it('should call cancel() on setting editable to false', () => {
const spy = spyOn(component, 'cancel').and.callThrough();
fixture.componentRef.setInput('editable', true);
expect(component.editable()).toBeTrue();
expect(component.editable()).toBe(true);
expect(spy).not.toHaveBeenCalled();

fixture.componentRef.setInput('editable', false);
component.ngOnChanges({ editable: new SimpleChange(true, false, false) });
expect(spy).toHaveBeenCalled();
expect(component.editable()).toBeFalse();
expect(component.editable()).toBe(false);
});

it('#addWidget() shall add a new WidgetConfig to the visible widgets of the grid and assign unique ids', () => {
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('SiGridComponent', () => {
component.edit();

component.isModified.subscribe(modified => {
expect(modified).toBeTrue();
expect(modified).toBe(true);
});
fixture.debugElement
.query(By.css('si-gridstack-wrapper'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('SiWidgetHostComponent', () => {
expect((component.primaryActions[0] as MenuItem).title).toBe('Hello User');
expect(component.primaryActions[1]).toBe(component.editAction);
expect(component.primaryActions[2]).toBe(component.removeAction);
expect(component.widgetInstance!.editable).toBeTrue();
expect(component.widgetInstance!.editable).toBe(true);
jasmine.clock().uninstall();
});

Expand All @@ -163,7 +163,7 @@ describe('SiWidgetHostComponent', () => {
expect(component.primaryActions.length).toBe(2);
expect(component.primaryActions[0]).toBe(component.editAction);
expect(component.primaryActions[1]).toBe(component.removeAction);
expect(component.widgetInstance!.editable).toBeTrue();
expect(component.widgetInstance!.editable).toBe(true);
jasmine.clock().uninstall();
});
});
Expand Down
4 changes: 2 additions & 2 deletions projects/dashboards-ng/src/widget-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ describe('widget-loader', () => {

describe('widgetFactoryRegistry', () => {
it('#hasFactoryFn() should return false for a not existing factory function', () => {
expect(widgetFactoryRegistry.hasFactoryFn('nothing')).toBeFalse();
expect(widgetFactoryRegistry.hasFactoryFn('nothing')).toBe(false);
});

it('#register() should add a factory function to the registry', () => {
const factoryFn = {} as SetupComponentFn;
widgetFactoryRegistry.register('my-function', factoryFn);
expect(widgetFactoryRegistry.hasFactoryFn('my-function')).toBeTrue();
expect(widgetFactoryRegistry.hasFactoryFn('my-function')).toBe(true);
expect(widgetFactoryRegistry.getFactoryFn('my-function')).toBe(factoryFn);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ describe('SiCollapsiblePanel', () => {
fixture.detectChanges();

const header = element.querySelector<HTMLElement>('.collapsible-header') as HTMLElement;
expect(header.classList.contains('open')).toBeFalse();
expect(header.classList.contains('open')).toBe(false);

toggleCollapsePanel();
fixture.detectChanges();

expect(header.classList.contains('open')).toBeTrue();
expect(header.classList.contains('open')).toBe(true);

const content = element.querySelector('.collapsible-content') as HTMLElement;
expect(content.innerHTML).toContain('This is the content');
Expand All @@ -81,20 +81,20 @@ describe('SiCollapsiblePanel', () => {
fixture.detectChanges();

const header = element.querySelector('.collapsible-header') as HTMLElement;
expect(header.classList.contains('open')).toBeFalse();
expect(header.classList.contains('open')).toBe(false);

toggleCollapsePanel();
fixture.detectChanges();

expect(header.classList.contains('open')).toBeTrue();
expect(header.classList.contains('open')).toBe(true);

const content = element.querySelector('.collapsible-content') as HTMLElement;
expect(content.innerHTML).toContain('This is the content');

toggleCollapsePanel();
fixture.detectChanges();

expect(header.classList.contains('open')).toBeFalse();
expect(header.classList.contains('open')).toBe(false);
});
it('should show show custom header selected by si-panel-heading directive', () => {
component.heading = 'This is the highlighted heading';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('SiLaunchpad', () => {
}
];
fixture.changeDetectorRef.markForCheck();
expect(await harness.hasToggle()).toBeTrue();
expect(await harness.hasToggle()).toBe(true);
expect(await harness.getCategories()).toHaveSize(1);
await harness.toggleMore();
expect(await harness.getCategories()).toHaveSize(2);
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('SiLaunchpad', () => {
expect(categories).toHaveSize(2);
expect(await categories[0].getName()).toBe('Favorites');
expect(await categories[1].getName()).toBe(null);
expect(await harness.getApp('A-1').then(app => app.isFavorite())).toBeTrue();
expect(await harness.getApp('A-1').then(app => app.isFavorite())).toBe(true);
expect(await harness.getFavoriteCategory().then(category => category.getApps())).toHaveSize(
1
);
Expand All @@ -132,7 +132,7 @@ describe('SiLaunchpad', () => {
}
];
fixture.changeDetectorRef.markForCheck();
expect(await harness.hasToggle()).toBeFalse();
expect(await harness.hasToggle()).toBe(false);
expect(await harness.getCategories()).toHaveSize(1);
});
});
Expand All @@ -144,7 +144,7 @@ describe('SiLaunchpad', () => {
{ name: 'A-2', href: '/a-2' }
];
fixture.changeDetectorRef.markForCheck();
expect(await harness.hasToggle()).toBeFalse();
expect(await harness.hasToggle()).toBe(false);
});
});
});
Expand Down
Loading
Loading