Skip to content

Commit

Permalink
fix: Address warnings and errors from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmccollum-woolpert committed Jul 8, 2024
1 parent ddcb2bc commit 7f4875c
Show file tree
Hide file tree
Showing 21 changed files with 131 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { Component, Input } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MaterialModule } from 'src/app/material';
import { BaseMainNavComponent } from './base-main-nav.component';
import { MatIconRegistry } from '@angular/material/icon';
import { FakeMatIconRegistry } from 'src/test/material-fakes';

@Component({
selector: 'app-generate-button',
Expand Down Expand Up @@ -55,7 +57,9 @@ describe('MainNavComponent', () => {
MockPreSolveMessageComponent,
BaseMainNavComponent,
],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

fixture = TestBed.createComponent(BaseMainNavComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,27 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DatasetComponent } from './dataset.component';
import { provideMockStore } from '@ngrx/store/testing';
import { selectScenarioName } from '../../selectors/dispatcher.selectors';
import { MaterialModule } from 'src/app/material';
import { FormsModule } from '@angular/forms';
import { MatIconRegistry } from '@angular/material/icon';
import { FakeMatIconRegistry } from 'src/test/material-fakes';

describe('DatasetComponent', () => {
let component: DatasetComponent;
let fixture: ComponentFixture<DatasetComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MaterialModule, FormsModule],
declarations: [DatasetComponent],
providers: [
provideMockStore({
selectors: [{ selector: selectScenarioName, value: '' }],
}),
],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

fixture = TestBed.createComponent(DatasetComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ limitations under the License.
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MapAddButtonsComponent } from './map-add-buttons.component';
import { MaterialModule } from 'src/app/material';
import { MatIconRegistry } from '@angular/material/icon';
import { FakeMatIconRegistry } from 'src/test/material-fakes';

describe('MapAddButtonsComponent', () => {
let component: MapAddButtonsComponent;
let fixture: ComponentFixture<MapAddButtonsComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MaterialModule],
declarations: [MapAddButtonsComponent],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

fixture = TestBed.createComponent(MapAddButtonsComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { MaterialModule } from 'src/app/material';
import { provideMockStore } from '@ngrx/store/testing';
import * as shipmentSelectors from '../../../core/selectors/shipment.selectors';
import ShipmentModelSelectors from '../../selectors/shipment-model.selectors';
import { MatIconRegistry } from '@angular/material/icon';
import { FakeMatIconRegistry } from 'src/test/material-fakes';

describe('PrecedenceRulesDialogComponent', () => {
let component: PrecedenceRulesDialogComponent;
Expand All @@ -36,7 +38,9 @@ describe('PrecedenceRulesDialogComponent', () => {
selectors: [{ selector: ShipmentModelSelectors.selectPrecedenceRules, value: [] }],
}),
],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

spyOnProperty(shipmentSelectors, 'selectAll').and.returnValue(() => []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { provideMockStore } from '@ngrx/store/testing';
import ShipmentModelSelectors from '../../selectors/shipment-model.selectors';
import ShipmentSelectors from '../../selectors/shipment.selectors';
import { selectShipmentTypes as selectScenarioShipmentTypes } from '../../../core/selectors/scenario.selectors';
import { MatIconRegistry } from '@angular/material/icon';
import { FakeMatIconRegistry } from 'src/test/material-fakes';

describe('ShipmentTypeIncompatibilityDialogComponent', () => {
let component: ShipmentTypeIncompatibilityDialogComponent;
Expand All @@ -43,7 +45,9 @@ describe('ShipmentTypeIncompatibilityDialogComponent', () => {
],
}),
],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

fixture = TestBed.createComponent(ShipmentTypeIncompatibilityDialogComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import ShipmentModelSelectors from '../../selectors/shipment-model.selectors';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import ShipmentSelectors from '../../selectors/shipment.selectors';
import { selectShipmentTypes as selectScenarioShipmentTypes } from '../../../core/selectors/scenario.selectors';
import { FakeMatIconRegistry } from 'src/test/material-fakes';
import { MatIconRegistry } from '@angular/material/icon';

describe('ShipmentTypeRequirementDialogComponent', () => {
let component: ShipmentTypeRequirementDialogComponent;
Expand All @@ -41,7 +43,9 @@ describe('ShipmentTypeRequirementDialogComponent', () => {
],
}),
],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

fixture = TestBed.createComponent(ShipmentTypeRequirementDialogComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TopBarComponent } from './top-bar.component';
import { provideMockStore } from '@ngrx/store/testing';
import { Component } from '@angular/core';

@Component({
selector: 'app-logo',
template: '',
})
export class MockLogoComponent {}

describe('TopBarComponent', () => {
let component: TopBarComponent;
let fixture: ComponentFixture<TopBarComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [TopBarComponent],
imports: [],
declarations: [TopBarComponent, MockLogoComponent],
providers: [provideMockStore()],
}).compileComponents();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class MockBodyComponent {
})
class MockSharedDefsComponent {}

@Component({
selector: 'app-top-bar',
template: '',
})
export class MockTopBarComponent {
@Input() started: boolean;
}

describe('AppComponent', () => {
let actions$: Observable<any>;

Expand All @@ -58,6 +66,7 @@ describe('AppComponent', () => {
MockBodyComponent,
MockSharedDefsComponent,
MockSideBarComponent,
MockTopBarComponent,
AppComponent,
],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CsvHelpDialogComponent } from './csv-help-dialog.component';
import { MatDialogRef } from '@angular/material/dialog';
import { MaterialModule } from 'src/app/material';
import { MatIconRegistry } from '@angular/material/icon';
import { FakeMatIconRegistry } from 'src/test/material-fakes';

describe('CsvHelpDialogComponent', () => {
let component: CsvHelpDialogComponent;
let fixture: ComponentFixture<CsvHelpDialogComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MaterialModule],
declarations: [CsvHelpDialogComponent],
providers: [{ provide: MatDialogRef, useValue: {} }],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

fixture = TestBed.createComponent(CsvHelpDialogComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ import ShipmentModelSelectors from '../../selectors/shipment-model.selectors';
import Long from 'long';
import { Page } from '../../models';
import * as fromUI from 'src/app/core/selectors/ui.selectors';
import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
selector: 'app-time-navigation',
})
class MockTimeNavigationComponent {
@Input() range: Range;
@Input() rangeOffset: number;
@Input() nowRangeOffset: number;
@Input() timezoneOffset = 0;
@Input() globalDuration: [Long, Long];
@Output() rangeOffsetChange = new EventEmitter<number>();
}

describe('RoutesChartControlBarComponent', () => {
let component: RoutesChartControlBarComponent;
Expand Down Expand Up @@ -68,7 +81,7 @@ describe('RoutesChartControlBarComponent', () => {
],
}),
],
declarations: [RoutesChartControlBarComponent],
declarations: [RoutesChartControlBarComponent, MockTimeNavigationComponent],
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ScenarioSolutionHelpDialogComponent } from './scenario-solution-help-dialog.component';
import { MatDialogRef } from '@angular/material/dialog';
import { MaterialModule } from 'src/app/material';
import { MatIconRegistry } from '@angular/material/icon';
import { FakeMatIconRegistry } from 'src/test/material-fakes';

describe('ScenarioSolutionHelpDialogComponent', () => {
let component: ScenarioSolutionHelpDialogComponent;
let fixture: ComponentFixture<ScenarioSolutionHelpDialogComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MaterialModule],
declarations: [ScenarioSolutionHelpDialogComponent],
providers: [{ provide: MatDialogRef, useValue: {} }],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

fixture = TestBed.createComponent(ScenarioSolutionHelpDialogComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { ShipmentModelSettingsComponent } from './shipment-model-settings.component';
import { provideMockStore } from '@ngrx/store/testing';
import { Component } from '@angular/core';
import { MaterialModule } from 'src/app/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

@Component({
selector: 'app-shipment-type-incompatibility-dialog',
Expand Down Expand Up @@ -67,6 +69,7 @@ describe('ShipmentModelSettingsComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MaterialModule, NoopAnimationsModule],
declarations: [
ShipmentModelSettingsComponent,
MockShipmentTypeIncompatibilityDialogComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ import { TravelSimulatorComponent } from './travel-simulator.component';
import { provideMockStore } from '@ngrx/store/testing';
import ShipmentModelSelectors from '../../selectors/shipment-model.selectors';
import TravelSimulatorSelectors from '../../selectors/travel-simulator.selectors';
import { MaterialModule } from 'src/app/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';

describe('TravelSimulatorComponent', () => {
let component: TravelSimulatorComponent;
let fixture: ComponentFixture<TravelSimulatorComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [MaterialModule, NoopAnimationsModule],
declarations: [TravelSimulatorComponent],
providers: [
provideMockStore({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { MaterialModule } from 'src/app/material';
import * as fromConfig from '../../selectors/config.selectors';
import { DispatcherService, FileService } from '../../services';
import { UploadDialogComponent } from './upload-dialog.component';
import { MatIconRegistry } from '@angular/material/icon';
import { FakeMatIconRegistry } from 'src/test/material-fakes';

describe('UploadDialogComponent', () => {
let component: UploadDialogComponent;
Expand All @@ -46,7 +48,9 @@ describe('UploadDialogComponent', () => {
selectors: [{ selector: fromConfig.selectMessagesConfig, value: null }],
}),
],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();

fixture = TestBed.createComponent(UploadDialogComponent);
component = fixture.componentInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ import ShipmentModelSelectors from '../../../core/selectors/shipment-model.selec
template: '',
})
class MockBaseRoutesRowComponent {
@Input() currentDragVisitIds: number[];
@Input() currentOverlapId: number;
@Input() isDragging: boolean;
@Input() route: ShipmentRoute;
@Input() vehicle: Vehicle;
@Input() shipmentCount: number;
Expand All @@ -66,15 +63,11 @@ class MockBaseRoutesRowComponent {
@Input() relaxationTimes: Long[];
@Input() timezoneOffset: number;
@Input() changedVisits: ChangedVisits;
@Input() color = '#1a73e8';
@Output() selectedChange = new EventEmitter<boolean>();
@Output() dragStart = new EventEmitter<PointOfInterestStartDrag>();
@Output() timelineEnter = new EventEmitter<PointOfInterestTimelineOverlapBegin>();
@Output() timelineLeave = new EventEmitter<number>();
@Output() pointOfInterestClick = new EventEmitter<PointOfInterestClick>();
@Output() editVehicle = new EventEmitter<number>();
@Output() viewMetadata = new EventEmitter<number>();
@Output() mouseEnterVisit = new EventEmitter<number>();
@Output() mouseExitVisit = new EventEmitter();
}

describe('RoutesRowComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export class MockPreSolveShipmentModelSettingsComponent {}
})
export class MockPreSolveGlobalSettingsComponent {}

@Component({
selector: 'app-pre-solve-settings',
template: '',
})
export class MockPreSolveSettingsComponent {}

describe('ScenarioPlanningComponent', () => {
let component: ScenarioPlanningComponent;
let fixture: ComponentFixture<ScenarioPlanningComponent>;
Expand All @@ -44,6 +50,7 @@ describe('ScenarioPlanningComponent', () => {
ScenarioPlanningComponent,
MockPreSolveShipmentModelSettingsComponent,
MockPreSolveGlobalSettingsComponent,
MockPreSolveSettingsComponent,
],
providers: [provideMockStore()],
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { MaterialModule } from 'src/app/material';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ErrorStateMatcher } from '@angular/material/core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { FakeMatIconRegistry } from 'src/test/material-fakes';
import { MatIconRegistry } from '@angular/material/icon';

const formDirective = new FormGroupDirective([], []);
formDirective.form = new UntypedFormGroup({
Expand Down Expand Up @@ -61,7 +63,9 @@ describe('BreakRuleFormComponent', () => {
imports: [MaterialModule, ReactiveFormsModule, NoopAnimationsModule],
declarations: [BreakRequestFormComponent, MockAppDurationMinSecFormComponent],
providers: [{ provide: ControlContainer, useValue: formDirective }],
}).compileComponents();
})
.overrideProvider(MatIconRegistry, { useFactory: () => new FakeMatIconRegistry() })
.compileComponents();
});

beforeEach(() => {
Expand Down
Loading

0 comments on commit 7f4875c

Please sign in to comment.