Back to home page

EIC code displayed by LXR

 
 

    


Warning, /firebird/firebird-ng/src/app/components/object-clipping/object-clipping.component.test.ts is written in an unsupported language. File is not indexed.

0001 import { ComponentFixture, TestBed } from '@angular/core/testing';
0002 
0003 import { ObjectClippingComponent } from './object-clipping.component';
0004 import { MatCheckboxChange } from '@angular/material/checkbox';
0005 import { EventDisplayService } from '../../../services/event-display.service';
0006 import { PhoenixUIModule } from '../../phoenix-ui.module';
0007 
0008 describe('ObjectClippingComponent', () => {
0009   let component: ObjectClippingComponent;
0010   let fixture: ComponentFixture<ObjectClippingComponent>;
0011 
0012   const mockUIManager = {
0013     rotateStartAngleClipping: jest.fn(),
0014     rotateOpeningAngleClipping: jest.fn(),
0015     setClipping: jest.fn(),
0016   };
0017 
0018   const mockEventDisplay = {
0019     getUIManager: jest.fn(() => mockUIManager),
0020     getStateManager: () => ({
0021       clippingEnabled: {
0022         onUpdate: jest.fn(),
0023       },
0024       startClippingAngle: {
0025         onUpdate: jest.fn(),
0026       },
0027       openingClippingAngle: {
0028         onUpdate: jest.fn(),
0029       },
0030     }),
0031   };
0032 
0033   beforeEach(() => {
0034     TestBed.configureTestingModule({
0035       imports: [PhoenixUIModule],
0036       providers: [
0037         {
0038           provide: EventDisplayService,
0039           useValue: mockEventDisplay,
0040         },
0041       ],
0042       declarations: [ObjectClippingComponent],
0043     }).compileComponents();
0044   });
0045 
0046   beforeEach(() => {
0047     fixture = TestBed.createComponent(ObjectClippingComponent);
0048     component = fixture.componentInstance;
0049     fixture.detectChanges();
0050   });
0051 
0052   it('should create', () => {
0053     expect(component).toBeTruthy();
0054   });
0055 
0056   it('should toggle clipping', () => {
0057     expect(component.clippingEnabled).toBeUndefined();
0058     const matCheckboxChange = new MatCheckboxChange();
0059 
0060     // Check for true
0061     matCheckboxChange.checked = true;
0062     component.toggleClipping(matCheckboxChange);
0063     expect(component.clippingEnabled).toBe(true);
0064 
0065     // Check for false
0066     matCheckboxChange.checked = false;
0067     component.toggleClipping(matCheckboxChange);
0068     expect(component.clippingEnabled).toBe(false);
0069   });
0070 
0071   it('should change clipping angle', () => {
0072     const sliderValue = 10;
0073 
0074     component.changeStartClippingAngle(sliderValue);
0075     expect(
0076       mockEventDisplay.getUIManager().rotateStartAngleClipping,
0077     ).toHaveBeenCalledWith(sliderValue);
0078 
0079     component.changeOpeningClippingAngle(sliderValue);
0080     expect(
0081       mockEventDisplay.getUIManager().rotateOpeningAngleClipping,
0082     ).toHaveBeenCalledWith(sliderValue);
0083   });
0084 });