244 lines
9.4 KiB
TypeScript
244 lines
9.4 KiB
TypeScript
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
import { GroupsComponent } from './groups.component';
|
|
import { MatInputModule } from '@angular/material/input';
|
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
import { MatButtonModule } from '@angular/material/button';
|
|
import { MatOptionModule } from '@angular/material/core';
|
|
import { MatDividerModule } from '@angular/material/divider';
|
|
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
import { MatIconModule } from '@angular/material/icon';
|
|
import { MatPaginatorModule } from '@angular/material/paginator';
|
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
import { MatSelectModule } from '@angular/material/select';
|
|
import { MatTableModule } from '@angular/material/table';
|
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
import { ToastrModule } from 'ngx-toastr';
|
|
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
|
import { MatAutocompleteModule } from '@angular/material/autocomplete';
|
|
import { MatListModule } from '@angular/material/list';
|
|
import { MatTabsModule } from '@angular/material/tabs';
|
|
import { MatCardModule } from '@angular/material/card';
|
|
import { TranslateModule } from '@ngx-translate/core';
|
|
import { JoyrideModule } from 'ngx-joyride';
|
|
import { AdvancedSearchComponent } from './components/advanced-search/advanced-search.component';
|
|
import { ClientTabViewComponent } from './components/client-tab-view/client-tab-view.component';
|
|
import { OrganizationalUnitTabViewComponent } from './components/organizational-unit-tab-view/organizational-unit-tab-view.component';
|
|
import { MatMenuModule } from '@angular/material/menu';
|
|
|
|
describe('GroupsComponent', () => {
|
|
let component: GroupsComponent;
|
|
let fixture: ComponentFixture<GroupsComponent>;
|
|
|
|
beforeEach(async () => {
|
|
await TestBed.configureTestingModule({
|
|
declarations: [GroupsComponent, AdvancedSearchComponent, ClientTabViewComponent, OrganizationalUnitTabViewComponent],
|
|
imports: [
|
|
HttpClientTestingModule,
|
|
ToastrModule.forRoot(),
|
|
BrowserAnimationsModule,
|
|
MatDividerModule,
|
|
MatFormFieldModule,
|
|
MatInputModule,
|
|
MatIconModule,
|
|
MatButtonModule,
|
|
MatTableModule,
|
|
MatPaginatorModule,
|
|
MatTooltipModule,
|
|
FormsModule,
|
|
ReactiveFormsModule,
|
|
MatProgressSpinnerModule,
|
|
MatDialogModule,
|
|
MatSelectModule,
|
|
MatTabsModule,
|
|
MatAutocompleteModule,
|
|
MatListModule,
|
|
MatCardModule,
|
|
MatMenuModule,
|
|
TranslateModule.forRoot(),
|
|
JoyrideModule.forRoot(),
|
|
],
|
|
providers: [
|
|
{ provide: MatDialogRef, useValue: {} },
|
|
{ provide: MAT_DIALOG_DATA, useValue: { data: { id: 123 } } }
|
|
]
|
|
})
|
|
.compileComponents();
|
|
|
|
fixture = TestBed.createComponent(GroupsComponent);
|
|
component = fixture.componentInstance;
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it('should create', () => {
|
|
expect(component).toBeTruthy();
|
|
});
|
|
|
|
it('should call search on ngOnInit', () => {
|
|
spyOn(component, 'search');
|
|
component.ngOnInit();
|
|
expect(component.search).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call getFilters on ngOnInit', () => {
|
|
spyOn(component, 'getFilters');
|
|
component.ngOnInit();
|
|
expect(component.getFilters).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call search method', () => {
|
|
spyOn(component, 'search');
|
|
component.search();
|
|
expect(component.search).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call getFilters method', () => {
|
|
spyOn(component, 'getFilters');
|
|
component.getFilters();
|
|
expect(component.getFilters).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call onTabChange method', () => {
|
|
spyOn(component, 'onTabChange');
|
|
const event = { index: 2 } as any;
|
|
component.onTabChange(event);
|
|
expect(component.onTabChange).toHaveBeenCalledWith(event);
|
|
});
|
|
|
|
it('should call onSelectUnidad method', () => {
|
|
spyOn(component, 'onSelectUnidad');
|
|
const unidad = { id: '1', name: 'Test' } as any;
|
|
component.onSelectUnidad(unidad);
|
|
expect(component.onSelectUnidad).toHaveBeenCalledWith(unidad);
|
|
});
|
|
|
|
it('should call onSelectChild method', () => {
|
|
spyOn(component, 'onSelectChild');
|
|
const child = { id: '1', name: 'Test', type: 'unit' } as any;
|
|
component.onSelectChild(child);
|
|
expect(component.onSelectChild).toHaveBeenCalledWith(child);
|
|
});
|
|
|
|
it('should call navigateToBreadcrumb method', () => {
|
|
spyOn(component, 'navigateToBreadcrumb');
|
|
component.navigateToBreadcrumb(1);
|
|
expect(component.navigateToBreadcrumb).toHaveBeenCalledWith(1);
|
|
});
|
|
|
|
it('should call loadChildrenAndClients method', () => {
|
|
spyOn(component, 'loadChildrenAndClients');
|
|
component.loadChildrenAndClients('1');
|
|
expect(component.loadChildrenAndClients).toHaveBeenCalledWith('1');
|
|
});
|
|
|
|
it('should call onDeleteClick method', () => {
|
|
spyOn(component, 'onDeleteClick');
|
|
const event = new MouseEvent('click');
|
|
component.onDeleteClick(event, 'uuid', 'name', 'client');
|
|
expect(component.onDeleteClick).toHaveBeenCalledWith(event, 'uuid', 'name', 'client');
|
|
});
|
|
|
|
it('should call onEditClick method', () => {
|
|
spyOn(component, 'onEditClick');
|
|
const event = new MouseEvent('click');
|
|
component.onEditClick(event, 'client', 'uuid');
|
|
expect(component.onEditClick).toHaveBeenCalledWith(event, 'client', 'uuid');
|
|
});
|
|
|
|
it('should call onShowClick method', () => {
|
|
spyOn(component, 'onShowClick');
|
|
const event = new MouseEvent('click');
|
|
component.onShowClick(event, { type: 'unit' });
|
|
expect(component.onShowClick).toHaveBeenCalledWith(event, { type: 'unit' });
|
|
});
|
|
|
|
it('should call onTreeClick method', () => {
|
|
spyOn(component, 'onTreeClick');
|
|
const event = new MouseEvent('click');
|
|
component.onTreeClick(event, { type: 'unit' });
|
|
expect(component.onTreeClick).toHaveBeenCalledWith(event, { type: 'unit' });
|
|
});
|
|
|
|
it('should call onExecuteCommand method', () => {
|
|
spyOn(component, 'onExecuteCommand');
|
|
const event = new MouseEvent('click');
|
|
component.onExecuteCommand(event, 'child', 'name', 'type');
|
|
expect(component.onExecuteCommand).toHaveBeenCalledWith(event, 'child', 'name', 'type');
|
|
});
|
|
|
|
it('should call openSnackBar method', () => {
|
|
spyOn(component, 'openSnackBar');
|
|
component.openSnackBar(true, 'message');
|
|
expect(component.openSnackBar).toHaveBeenCalledWith(true, 'message');
|
|
});
|
|
|
|
it('should call openBottomSheet method', () => {
|
|
spyOn(component, 'openBottomSheet');
|
|
component.openBottomSheet();
|
|
expect(component.openBottomSheet).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call roomMap method', () => {
|
|
spyOn(component, 'roomMap');
|
|
component.roomMap();
|
|
expect(component.roomMap).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call applyFilter method', () => {
|
|
spyOn(component, 'applyFilter');
|
|
component.applyFilter();
|
|
expect(component.applyFilter).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call onPageChange method', () => {
|
|
spyOn(component, 'onPageChange');
|
|
const event = { pageIndex: 1, pageSize: 10 } as any;
|
|
component.onPageChange(event);
|
|
expect(component.onPageChange).toHaveBeenCalledWith(event);
|
|
});
|
|
|
|
it('should call saveFilters method', () => {
|
|
spyOn(component, 'saveFilters');
|
|
component.saveFilters();
|
|
expect(component.saveFilters).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call loadSelectedFilter method', () => {
|
|
spyOn(component, 'loadSelectedFilter');
|
|
component.loadSelectedFilter(['name', 'uuid']);
|
|
expect(component.loadSelectedFilter).toHaveBeenCalledWith(['name', 'uuid']);
|
|
});
|
|
|
|
it('should call onCheckboxChange method', () => {
|
|
spyOn(component, 'onCheckboxChange');
|
|
const event = { checked: true } as any;
|
|
component.onCheckboxChange(event, 'name', 'uuid');
|
|
expect(component.onCheckboxChange).toHaveBeenCalledWith(event, 'name', 'uuid');
|
|
});
|
|
|
|
it('should call toggleSelectAll method', () => {
|
|
spyOn(component, 'toggleSelectAll');
|
|
component.toggleSelectAll();
|
|
expect(component.toggleSelectAll).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call isSelected method', () => {
|
|
spyOn(component, 'isSelected');
|
|
component.isSelected('name');
|
|
expect(component.isSelected).toHaveBeenCalledWith('name');
|
|
});
|
|
|
|
it('should call sendActions method', () => {
|
|
spyOn(component, 'sendActions');
|
|
component.sendActions();
|
|
expect(component.sendActions).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should call iniciarTour method', () => {
|
|
spyOn(component, 'iniciarTour');
|
|
component.iniciarTour();
|
|
expect(component.iniciarTour).toHaveBeenCalled();
|
|
});
|
|
});
|