diff --git a/src/app/components/project-map/console-wrapper/console-wrapper.component.spec.ts b/src/app/components/project-map/console-wrapper/console-wrapper.component.spec.ts index 6f2b6d75..c9753326 100644 --- a/src/app/components/project-map/console-wrapper/console-wrapper.component.spec.ts +++ b/src/app/components/project-map/console-wrapper/console-wrapper.component.spec.ts @@ -1,21 +1,47 @@ +import { ComponentFixture, TestBed, async } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ToasterService } from '../../../services/toaster.service'; import { MapSettingsService } from '../../../services/mapsettings.service'; import { NodeConsoleService } from '../../../services/nodeConsole.service'; import { ThemeService } from '../../../services/theme.service'; import { ConsoleWrapperComponent } from './console-wrapper.component'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; describe('ConsoleWrapperComponent', () => { + let fixture: ComponentFixture; + let component: ConsoleWrapperComponent; + + let nodeConsoleService: NodeConsoleService; + let themeService: ThemeService; + let mapSettingsService: MapSettingsService; + let toasterService: ToasterService; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [RouterTestingModule, MatSnackBarModule], + providers: [NodeConsoleService, ThemeService, MapSettingsService, ToasterService] + }).compileComponents(); + + toasterService = TestBed.inject(ToasterService); + nodeConsoleService = TestBed.inject(NodeConsoleService); + themeService = TestBed.inject(ThemeService); + mapSettingsService = TestBed.inject(MapSettingsService); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ConsoleWrapperComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should be created', () => { + expect(component).toBeTruthy(); + }); + it('should get actual theme', () => { - const consoleService = new NodeConsoleService(); - - const themeService = autoSpy(ThemeService); - themeService.getActualTheme.and.returnValue('light'); - - const mapSettingsService = autoSpy(MapSettingsService); - const component = new ConsoleWrapperComponent(consoleService, themeService, mapSettingsService); - component.ngOnInit(); - expect(component.isLightThemeEnabled).toBe(true); + expect(component.isLightThemeEnabled).toBe(false); }); }); diff --git a/src/app/components/project-map/context-console-menu/context-console-menu.component.spec.ts b/src/app/components/project-map/context-console-menu/context-console-menu.component.spec.ts index 8f51d1b8..dbd0d098 100644 --- a/src/app/components/project-map/context-console-menu/context-console-menu.component.spec.ts +++ b/src/app/components/project-map/context-console-menu/context-console-menu.component.spec.ts @@ -1,6 +1,7 @@ import { ChangeDetectorRef, NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { MatMenuModule } from '@angular/material/menu'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; import { BrowserModule } from '@angular/platform-browser'; import { Router } from '@angular/router'; import { ElectronService } from 'ngx-electron'; @@ -20,7 +21,9 @@ import { ContextConsoleMenuComponent } from './context-console-menu.component'; describe('ContextConsoleMenuComponent', () => { let component: ContextConsoleMenuComponent; let fixture: ComponentFixture; - let toasterService: MockedToasterService = new MockedToasterService(); + let nodeConsoleService: NodeConsoleService; + let mapSettingsService: MapSettingsService; + let toasterService: ToasterService; let router = { url: '', navigate: jasmine.createSpy('navigate'), @@ -28,7 +31,6 @@ describe('ContextConsoleMenuComponent', () => { let node = { status: 'started', }; - let mapSettingsService = new MapSettingsService(); beforeEach(async(() => { const electronMock = { @@ -36,20 +38,25 @@ describe('ContextConsoleMenuComponent', () => { }; TestBed.configureTestingModule({ - imports: [MatMenuModule, BrowserModule], + imports: [MatMenuModule, BrowserModule, MatSnackBarModule], providers: [ { provide: ChangeDetectorRef }, { provide: ProjectService, useClass: MockedProjectService }, { provide: ElectronService, useValue: electronMock }, { provide: MapSettingsService, useValue: mapSettingsService }, - { provide: NodeConsoleService }, { provide: ConsoleService }, - { provide: ToasterService, useValue: toasterService }, { provide: Router, useValue: router }, + NodeConsoleService, + ToasterService, + MapSettingsService ], declarations: [ContextConsoleMenuComponent, ConsoleDeviceActionComponent, ConsoleDeviceActionBrowserComponent], schemas: [NO_ERRORS_SCHEMA], }).compileComponents(); + + toasterService = TestBed.inject(ToasterService); + mapSettingsService = TestBed.inject(MapSettingsService); + nodeConsoleService = TestBed.inject(NodeConsoleService); })); beforeEach(() => { diff --git a/src/app/components/project-map/log-console/log-console.component.spec.ts b/src/app/components/project-map/log-console/log-console.component.spec.ts index 4426d5c7..1d7886c3 100644 --- a/src/app/components/project-map/log-console/log-console.component.spec.ts +++ b/src/app/components/project-map/log-console/log-console.component.spec.ts @@ -13,7 +13,6 @@ import { Server } from '../../../models/server'; import { HttpServer, ServerErrorHandler } from '../../../services/http-server.service'; import { NodeService } from '../../../services/node.service'; import { NodeConsoleService } from '../../../services/nodeConsole.service'; -import { MockedNodeConsoleService } from '../console-wrapper/console-wrapper.component.spec'; import { MockedNodesDataSource, MockedNodeService } from '../project-map.component.spec'; import { LogConsoleComponent } from './log-console.component'; import { LogEventsDataSource } from './log-events-datasource';