diff --git a/wowup-electron/src/app/components/install-from-protocol-dialog/install-from-protocol-dialog.component.spec.ts b/wowup-electron/src/app/components/install-from-protocol-dialog/install-from-protocol-dialog.component.spec.ts index 5e7f9bc8..731c4cce 100644 --- a/wowup-electron/src/app/components/install-from-protocol-dialog/install-from-protocol-dialog.component.spec.ts +++ b/wowup-electron/src/app/components/install-from-protocol-dialog/install-from-protocol-dialog.component.spec.ts @@ -1,16 +1,75 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { HttpClient, HttpClientModule } from "@angular/common/http"; +import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core"; +import { ComponentFixture, TestBed } from "@angular/core/testing"; +import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; +import { NoopAnimationsModule } from "@angular/platform-browser/animations"; +import { TranslateCompiler, TranslateLoader, TranslateModule } from "@ngx-translate/core"; +import { TranslateMessageFormatCompiler } from "ngx-translate-messageformat-compiler"; +import { httpLoaderFactory } from "../../app.module"; +import { MatModule } from "../../mat-module"; +import { AddonService } from "../../services/addons/addon.service"; +import { IconService } from "../../services/icons/icon.service"; +import { SessionService } from "../../services/session/session.service"; +import { WarcraftInstallationService } from "../../services/warcraft/warcraft-installation.service"; +import { overrideIconModule } from "../../tests/mock-mat-icon"; -import { InstallFromProtocolDialogComponent } from './install-from-protocol-dialog.component'; +import { + InstallFromProtocolDialogComponent, + InstallFromProtocolDialogComponentData, +} from "./install-from-protocol-dialog.component"; -describe('InstallFromProtocolDialogComponent', () => { +describe("InstallFromProtocolDialogComponent", () => { let component: InstallFromProtocolDialogComponent; let fixture: ComponentFixture; + let addonService: AddonService; + let sessionService: SessionService; + let warcraftInstallationService: WarcraftInstallationService; + let dialogModel: InstallFromProtocolDialogComponentData; beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ InstallFromProtocolDialogComponent ] - }) - .compileComponents(); + addonService = jasmine.createSpyObj("AddonService", [""], {}); + + sessionService = jasmine.createSpyObj("SessionService", [""], {}); + + warcraftInstallationService = jasmine.createSpyObj("WarcraftInstallationService", [""], {}); + + dialogModel = { protocol: "" }; + + let testBed = TestBed.configureTestingModule({ + declarations: [InstallFromProtocolDialogComponent], + imports: [ + MatModule, + HttpClientModule, + NoopAnimationsModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: httpLoaderFactory, + deps: [HttpClient], + }, + compiler: { + provide: TranslateCompiler, + useClass: TranslateMessageFormatCompiler, + }, + }), + ], + schemas: [CUSTOM_ELEMENTS_SCHEMA], + providers: [{ provide: MAT_DIALOG_DATA, useValue: dialogModel }], + }); + + testBed = overrideIconModule(testBed).overrideComponent(InstallFromProtocolDialogComponent, { + set: { + providers: [ + { provide: MatDialogRef, useValue: {} }, + { provide: AddonService, useValue: addonService }, + { provide: SessionService, useValue: sessionService }, + { provide: WarcraftInstallationService, useValue: warcraftInstallationService }, + { provide: IconService }, + ], + }, + }); + + await testBed.compileComponents(); }); beforeEach(() => { @@ -19,7 +78,7 @@ describe('InstallFromProtocolDialogComponent', () => { fixture.detectChanges(); }); - it('should create', () => { + it("should create", () => { expect(component).toBeTruthy(); }); }); diff --git a/wowup-electron/src/app/components/install-from-protocol-dialog/install-from-protocol-dialog.component.ts b/wowup-electron/src/app/components/install-from-protocol-dialog/install-from-protocol-dialog.component.ts index 89f8621e..33949e43 100644 --- a/wowup-electron/src/app/components/install-from-protocol-dialog/install-from-protocol-dialog.component.ts +++ b/wowup-electron/src/app/components/install-from-protocol-dialog/install-from-protocol-dialog.component.ts @@ -1,14 +1,16 @@ +import * as _ from "lodash"; +import { from, of } from "rxjs"; +import { catchError, delay, first, switchMap } from "rxjs/operators"; + import { AfterViewInit, Component, Inject, OnInit } from "@angular/core"; import { FormControl } from "@angular/forms"; -import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material/dialog"; -import { ProtocolSearchResult } from "app/models/wowup/protocol-search-result"; -import { WowInstallation } from "app/models/wowup/wow-installation"; -import { SessionService } from "app/services/session/session.service"; -import { WarcraftInstallationService } from "app/services/warcraft/warcraft-installation.service"; -import * as _ from "lodash"; -import { BehaviorSubject, from, of, Subject } from "rxjs"; -import { catchError, delay, filter, first, map, switchMap } from "rxjs/operators"; +import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; + +import { ProtocolSearchResult } from "../../models/wowup/protocol-search-result"; +import { WowInstallation } from "../../models/wowup/wow-installation"; import { AddonService } from "../../services/addons/addon.service"; +import { SessionService } from "../../services/session/session.service"; +import { WarcraftInstallationService } from "../../services/warcraft/warcraft-installation.service"; export interface InstallFromProtocolDialogComponentData { protocol: string; diff --git a/wowup-electron/src/app/components/options-app-section/options-app-section.component.spec.ts b/wowup-electron/src/app/components/options-app-section/options-app-section.component.spec.ts index 0a8765b0..cecacca7 100644 --- a/wowup-electron/src/app/components/options-app-section/options-app-section.component.spec.ts +++ b/wowup-electron/src/app/components/options-app-section/options-app-section.component.spec.ts @@ -38,6 +38,7 @@ describe("OptionsAppSectionComponent", () => { { getZoomFactor: Promise.resolve(1.0), onRendererEvent: () => undefined, + isDefaultProtocolClient: Promise.resolve(false), }, { isWin: false, diff --git a/wowup-electron/src/app/models/wowup/protocol-search-result.ts b/wowup-electron/src/app/models/wowup/protocol-search-result.ts index 13489991..1cf3b4d1 100644 --- a/wowup-electron/src/app/models/wowup/protocol-search-result.ts +++ b/wowup-electron/src/app/models/wowup/protocol-search-result.ts @@ -1,4 +1,4 @@ -import { WowClientType } from "common/warcraft/wow-client-type"; +import { WowClientType } from "../../../common/warcraft/wow-client-type"; import { AddonSearchResult } from "./addon-search-result"; export interface ProtocolSearchResult extends AddonSearchResult { diff --git a/wowup-electron/src/app/pages/home/home.component.spec.ts b/wowup-electron/src/app/pages/home/home.component.spec.ts index 9ecdb096..e2621804 100644 --- a/wowup-electron/src/app/pages/home/home.component.spec.ts +++ b/wowup-electron/src/app/pages/home/home.component.spec.ts @@ -15,6 +15,7 @@ import { MatModule } from "../../mat-module"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { AddonScanError, AddonSyncError } from "../../errors"; import { WarcraftInstallationService } from "../../services/warcraft/warcraft-installation.service"; +import { DialogFactory } from "../../services/dialog/dialog.factory"; describe("HomeComponent", () => { let electronService: ElectronService; @@ -22,8 +23,11 @@ describe("HomeComponent", () => { let sessionService: SessionService; let addonService: AddonService; let warcraftInstallationService: WarcraftInstallationService; + let dialogFactory: DialogFactory; beforeEach(async () => { + dialogFactory = jasmine.createSpyObj("DialogFactory", [""], {}); + warcraftInstallationService = jasmine.createSpyObj("WarcraftInstallationService", [""], { wowInstallations$: new BehaviorSubject([]), }); @@ -39,6 +43,7 @@ describe("HomeComponent", () => { isLinux: true, isMax: false, powerMonitor$: new Observable(), + customProtocol$: new Observable(), }); wowUpService = jasmine.createSpyObj("WowUpService", { @@ -75,6 +80,7 @@ describe("HomeComponent", () => { { provide: SessionService, useValue: sessionService }, { provide: AddonService, useValue: addonService }, { provide: WowUpService, useValue: wowUpService }, + { provide: DialogFactory, useValue: dialogFactory }, { provide: WarcraftInstallationService, useValue: warcraftInstallationService }, ], }, diff --git a/wowup-electron/src/app/pages/home/home.component.ts b/wowup-electron/src/app/pages/home/home.component.ts index 45dfac75..a0bdbef7 100644 --- a/wowup-electron/src/app/pages/home/home.component.ts +++ b/wowup-electron/src/app/pages/home/home.component.ts @@ -12,16 +12,16 @@ import { IPC_POWER_MONITOR_UNLOCK, } from "../../../common/constants"; import { AppConfig } from "../../../environments/environment"; +import { InstallFromProtocolDialogComponent } from "../../components/install-from-protocol-dialog/install-from-protocol-dialog.component"; import { AddonScanError } from "../../errors"; import { WowInstallation } from "../../models/wowup/wow-installation"; import { ElectronService } from "../../services"; import { AddonService, ScanUpdate, ScanUpdateType } from "../../services/addons/addon.service"; +import { DialogFactory } from "../../services/dialog/dialog.factory"; import { SessionService } from "../../services/session/session.service"; import { WarcraftInstallationService } from "../../services/warcraft/warcraft-installation.service"; import { WowUpService } from "../../services/wowup/wowup.service"; -import { DialogFactory } from "../../services/dialog/dialog.factory"; import { getProtocol } from "../../utils/string.utils"; -import { InstallFromProtocolDialogComponent } from "app/components/install-from-protocol-dialog/install-from-protocol-dialog.component"; @Component({ selector: "app-home", diff --git a/wowup-electron/src/app/pages/my-addons/my-addons.component.spec.ts b/wowup-electron/src/app/pages/my-addons/my-addons.component.spec.ts index cfa30967..ed35664d 100644 --- a/wowup-electron/src/app/pages/my-addons/my-addons.component.spec.ts +++ b/wowup-electron/src/app/pages/my-addons/my-addons.component.spec.ts @@ -70,6 +70,7 @@ describe("MyAddonsComponent", () => { selectedHomeTab$: new BehaviorSubject(0).asObservable(), autoUpdateComplete$: new BehaviorSubject(0).asObservable(), selectedClientType$: new BehaviorSubject(WowClientType.Retail).asObservable(), + targetFileInstallComplete$: new Subject(), addonsChanged$: new BehaviorSubject([]), }); warcraftServiceSpy = jasmine.createSpyObj("WarcraftService", [""], {