@ngx-translate/core#TranslateCompiler TypeScript Examples

The following examples show how to use @ngx-translate/core#TranslateCompiler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: test.utils.ts    From WowUp with GNU General Public License v3.0 7 votes vote down vote up
export function createTranslateModule(): ModuleWithProviders<TranslateModule> {
  return TranslateModule.forRoot({
    loader: {
      provide: TranslateLoader,
      useFactory: testHttpLoaderFactory,
      deps: [HttpClient],
    },
    compiler: {
      provide: TranslateCompiler,
      useClass: TranslateMessageFormatCompiler,
    },
  });
}
Example #2
Source File: i18n.constants.ts    From geonetwork-ui with GNU General Public License v2.0 6 votes vote down vote up
TRANSLATE_GEONETWORK_CONFIG = {
  compiler: {
    provide: TranslateCompiler,
    useClass: TranslateMessageFormatCompiler,
  },
  loader: {
    provide: TranslateLoader,
    useClass: Gn4TranslateLoader,
    deps: [ToolsApiService],
  },
}
Example #3
Source File: i18n.constants.ts    From geonetwork-ui with GNU General Public License v2.0 6 votes vote down vote up
TRANSLATE_DEFAULT_CONFIG = {
  compiler: {
    provide: TranslateCompiler,
    useClass: TranslateMessageFormatCompiler,
  },
  loader: {
    provide: TranslateLoader,
    useFactory: HttpLoaderFactory,
    defaultLanguage: DEFAULT_LANG,
    deps: [HttpClient],
  },
}
Example #4
Source File: test-helpers.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
export function getStandardImports(): any[] {
  return [
    MatModule,
    HttpClientModule,
    BrowserAnimationsModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: httpLoaderFactoryTest,
        deps: [HttpClient],
      },
      compiler: {
        provide: TranslateCompiler,
        useClass: TranslateMessageFormatCompiler,
      },
    }),
  ];
}
Example #5
Source File: relative-duration-pipe.spec.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
describe("RelativeDurationPipe", () => {
  let component: TestRelativeDurationComponent;
  let fixture: ComponentFixture<TestRelativeDurationComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [TestRelativeDurationComponent, RelativeDurationPipe],
      imports: [
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    }).compileComponents();

    fixture = TestBed.createComponent(TestRelativeDurationComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #6
Source File: get-addon-list-item-file-prop.pipe.spec.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
describe("GetAddonListItemFilePropPipe", () => {
  let component: TestAddonListItemFilePropComponent;
  let fixture: ComponentFixture<TestAddonListItemFilePropComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [TestAddonListItemFilePropComponent, GetAddonListItemFilePropPipe],
      imports: [
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    }).compileComponents();

    fixture = TestBed.createComponent(TestAddonListItemFilePropComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #7
Source File: progress-spinner.component.spec.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
describe("ProgressSpinnerComponent", () => {
  let component: ProgressSpinnerComponent;
  let fixture: ComponentFixture<ProgressSpinnerComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [ProgressSpinnerComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      schemas: [CUSTOM_ELEMENTS_SCHEMA],
    }).compileComponents();

    fixture = TestBed.createComponent(ProgressSpinnerComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #8
Source File: alert-dialog.component.spec.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
describe("AlertDialogComponent", () => {
  let linkService: any;

  beforeEach(async () => {
    linkService = jasmine.createSpyObj("LinkService", [""], {});

    await TestBed.configureTestingModule({
      declarations: [AlertDialogComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      providers: [
        { provide: MAT_DIALOG_DATA, useValue: {} },
        { provide: MatDialogRef, useValue: {} },
        { provide: LinkService, useValue: linkService },
      ],
    }).compileComponents();
  });

  it("should create", () => {
    const fixture = TestBed.createComponent(AlertDialogComponent);
    expect(fixture.componentInstance).toBeTruthy();
  });
});
Example #9
Source File: confirm-dialog.component.spec.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
describe("ConfirmDialogComponent", () => {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [ConfirmDialogComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      providers: [
        { provide: MAT_DIALOG_DATA, useValue: {} },
        { provide: MatDialogRef, useValue: {} },
      ],
    }).compileComponents();
  });

  it("should create", () => {
    const fixture = TestBed.createComponent(ConfirmDialogComponent);
    expect(fixture.componentInstance).toBeTruthy();
  });
});
Example #10
Source File: telemetry-dialog.component.spec.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
describe("TelemetryDialogComponent", () => {
  let component: TelemetryDialogComponent;
  let fixture: ComponentFixture<TelemetryDialogComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [TelemetryDialogComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      providers: [{ provide: MatDialogRef, useValue: {} }],
    }).compileComponents();

    fixture = TestBed.createComponent(TelemetryDialogComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #11
Source File: options-wow-section.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("OptionsWowSectionComponent", () => {
  let component: OptionsWowSectionComponent;
  let fixture: ComponentFixture<OptionsWowSectionComponent>;
  let wowUpServiceSpy: WowUpService;
  let warcraftServiceSpy: WarcraftService;
  let warcraftInstallationService: WarcraftInstallationService;

  beforeEach(async () => {
    warcraftServiceSpy = jasmine.createSpyObj(
      "WarcraftService",
      {
        getClientFolderName: (clientType: WowClientType) => clientType.toString(),
        getClientLocation: (clientType: WowClientType) => clientType.toString(),
      },
      {
        products$: new BehaviorSubject<InstalledProduct[]>([]).asObservable(),
      }
    );

    wowUpServiceSpy = jasmine.createSpyObj(
      "WowUpService",
      {
        getDefaultAddonChannel: () => AddonChannelType.Stable,
        getDefaultAutoUpdate: () => false,
      },
      {
        wowUpReleaseChannel: WowUpReleaseChannelType.Stable,
      }
    );

    warcraftInstallationService = jasmine.createSpyObj("WarcraftInstallationService", [""], {
      wowInstallations$: new BehaviorSubject<any[]>([]),
    });

    await TestBed.configureTestingModule({
      declarations: [OptionsWowSectionComponent, WowClientOptionsComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        MatDialogModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      providers: [MatDialog],
    })
      .overrideComponent(OptionsWowSectionComponent, {
        set: {
          providers: [
            { provide: WowUpService, useValue: wowUpServiceSpy },
            { provide: WarcraftService, useValue: warcraftServiceSpy },
            { provide: WarcraftInstallationService, useValue: warcraftInstallationService },
          ],
        },
      })
      .compileComponents();

    fixture = TestBed.createComponent(OptionsWowSectionComponent);
    component = fixture.componentInstance;

    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #12
Source File: options-debug-section.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("OptionsDebugSectionComponent", () => {
  let component: OptionsDebugSectionComponent;
  let fixture: ComponentFixture<OptionsDebugSectionComponent>;
  let addonServiceSpy: any;
  let wowUpServiceSpy: any;
  let sessionService: any;

  beforeEach(async () => {
    addonServiceSpy = jasmine.createSpyObj(AddonService, ["logDebugData"]);
    wowUpServiceSpy = jasmine.createSpyObj(WowUpService, ["showLogsFolder"]);
    sessionService = jasmine.createSpyObj("SessionService", [""], {});

    await TestBed.configureTestingModule({
      declarations: [OptionsDebugSectionComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(OptionsDebugSectionComponent, {
        set: {
          providers: [
            { provide: AddonService, useValue: addonServiceSpy },
            { provide: WowUpService, useValue: wowUpServiceSpy },
            { provide: SessionService, useValue: sessionService },
          ],
        },
      })
      .compileComponents();

    fixture = TestBed.createComponent(OptionsDebugSectionComponent);
    component = fixture.componentInstance;

    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });

  it("Should call logDebugData", fakeAsync(() => {
    const button = fixture.debugElement.nativeElement.querySelector("#dump-debug-btn");
    button.click();
    tick();
    expect(addonServiceSpy.logDebugData).toHaveBeenCalled();
  }));

  it("Should call showLogFiles", fakeAsync(() => {
    const button = fixture.debugElement.nativeElement.querySelector("#show-log-btn");
    button.click();
    tick();
    expect(wowUpServiceSpy.showLogsFolder).toHaveBeenCalled();
  }));
});
Example #13
Source File: wow-client-options.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("WowClientOptionsComponent", () => {
  let component: WowClientOptionsComponent;
  let fixture: ComponentFixture<WowClientOptionsComponent>;
  let warcraftInstallationService: WarcraftInstallationService;
  let warcraftService: WarcraftService;
  let sessionService: any;

  beforeEach(async () => {
    mockPreload();

    warcraftInstallationService = jasmine.createSpyObj("WarcraftInstallationService", ["getWowInstallations"], {
      wowInstallations$: new BehaviorSubject([]),
      getWowInstallation: () => {
        return {
          clientType: WowClientType.Beta,
        };
      },
    });

    warcraftService = jasmine.createSpyObj("WarcraftService", ["getExecutableName"], {});
    sessionService = jasmine.createSpyObj("SessionService", [""], {
      editingWowInstallationId$: new Observable(),
    });

    let testBed = TestBed.configureTestingModule({
      declarations: [WowClientOptionsComponent],
      imports: [
        MatModule,
        FormsModule,
        HttpClientModule,
        BrowserAnimationsModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      providers: [MatDialog],
    });
    testBed = overrideIconModule(testBed).overrideComponent(WowClientOptionsComponent, {
      set: {
        providers: [
          { provide: WarcraftInstallationService, useValue: warcraftInstallationService },
          { provide: WarcraftService, useValue: warcraftService },
          { provide: SessionService, useValue: sessionService },
        ],
      },
    });
    await testBed.compileComponents();
    fixture = TestBed.createComponent(WowClientOptionsComponent);
    component = fixture.componentInstance;
    component.installationId = "1";
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #14
Source File: home.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("HomeComponent", () => {
  let electronService: ElectronService;
  let wowUpService: WowUpService;
  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<any[]>([]),
    });

    addonService = jasmine.createSpyObj("AddonService", [""], {
      scanUpdate$: new BehaviorSubject<ScanUpdate>({ type: ScanUpdateType.Unknown }).asObservable(),
      syncError$: new Subject<AddonSyncError>(),
      scanError$: new Subject<AddonScanError>(),
      addonInstalled$: new Subject<AddonUpdateEvent>(),
    });

    electronService = jasmine.createSpyObj("ElectronService", [""], {
      isWin: false,
      isLinux: true,
      isMax: false,
      powerMonitor$: new Observable(),
      customProtocol$: new Observable(),
    });

    wowUpService = jasmine.createSpyObj("WowUpService", {
      checkForAppUpdate: () => Promise.resolve(undefined),
    });

    sessionService = jasmine.createSpyObj("SessionService", [""], {});

    await TestBed.configureTestingModule({
      declarations: [HomeComponent],
      imports: [
        MatModule,
        HttpClientModule,
        BrowserAnimationsModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
        GalleryModule,
        LightboxModule,
      ],
      providers: [MatSnackBar],
      schemas: [CUSTOM_ELEMENTS_SCHEMA],
    })
      .overrideComponent(HomeComponent, {
        set: {
          providers: [
            { provide: ElectronService, useValue: electronService },
            { provide: SessionService, useValue: sessionService },
            { provide: AddonService, useValue: addonService },
            { provide: WowUpService, useValue: wowUpService },
            { provide: DialogFactory, useValue: dialogFactory },
            { provide: WarcraftInstallationService, useValue: warcraftInstallationService },
          ],
        },
      })
      .compileComponents();
  });

  it("should create", () => {
    const fixture = TestBed.createComponent(HomeComponent);
    expect(fixture.componentInstance).toBeTruthy();
  });
});
Example #15
Source File: options.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("OptionsComponent", () => {
  let component: OptionsComponent;
  let fixture: ComponentFixture<OptionsComponent>;
  let electronServiceSpy: any;
  let wowUpServiceSpy: any;
  let sessionService: any;

  beforeEach(async () => {
    sessionService = jasmine.createSpyObj("SessionService", [""], {
      currentTheme$: new BehaviorSubject("default-theme"),
    });

    wowUpServiceSpy = jasmine.createSpyObj(
      "WowUpService",
      {},
      {
        currentTheme: "horde ofc",
      }
    );
    electronServiceSpy = jasmine.createSpyObj("ElectronService", [""], {
      isWin: false,
      isLinux: true,
      isMac: false,
    });

    await TestBed.configureTestingModule({
      declarations: [OptionsComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      schemas: [CUSTOM_ELEMENTS_SCHEMA],
    })
      .overrideComponent(OptionsComponent, {
        set: {
          providers: [
            { provide: ElectronService, useValue: electronServiceSpy },
            { provide: SessionService, useValue: sessionService },
            { provide: WowUpService, useValue: wowUpServiceSpy },
          ],
        },
      })
      .compileComponents();

    fixture = TestBed.createComponent(OptionsComponent);
    component = fixture.componentInstance;

    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #16
Source File: download-count.pipe.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("DownloadCountPipe", () => {
  let component: TestDownloadCountComponent;
  let fixture: ComponentFixture<TestDownloadCountComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [TestDownloadCountComponent, DownloadCountPipe],
      imports: [
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    }).compileComponents();
    fixture = TestBed.createComponent(TestDownloadCountComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });

  const inputs = {
    "e+0": 1,
    "e+1": 10,
    "e+2": 100,
    "e+3": 1000,
    "e+4": 10000,
    "e+5": 100000,
    "e+6": 1000000,
    "e+7": 10000000,
    "e+8": 100000000,
    "e+9": 1000000000,
  };

  for (const index in inputs) {
    const number: number = inputs[index];
    it(`should transform the number ${number} to ${index}`, () => {
      component.number = number;
      fixture.detectChanges();
      const p = fixture.debugElement.nativeElement.querySelector("p");
      expect(p.innerHTML).toBe(`COMMON.DOWNLOAD_COUNT.${index}`);
    });
  }
});
Example #17
Source File: locales.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("LocaleTest", () => {
  let translate: TranslateService;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [],
      imports: [
        HttpClientModule,
        TranslateModule.forRoot({
          loader: { provide: TranslateLoader, useClass: JsonTranslationLoader },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      providers: [],
    })
      .compileComponents()
      .catch((e) => console.error(e));
  });

  beforeEach(() => {
    translate = TestBed.inject(TranslateService);
  });

  LOCALES.forEach((locale) => {
    describe(`${locale}:`, () => {
      beforeEach(async () => {
        await translate.use(locale).toPromise();
      });

      const localeKeys = loadLocaleKeys(locale);
      for (const lk of Object.keys(localeKeys)) {
        it(`should have translated value ${locale}:${lk}`, async () => {
          await translate
            .get(lk, { count: 1, myriadCount: 2, rawCount: 3, addonNames: "test1, test2" })
            .toPromise()
            .catch((e) => console.error(e))
            .then((translated) => {
              expect(translated === lk).toBeFalse();
            });
        });
      }
    });
  });

  function loadLocaleKeys(locale: string): { [key: string]: string } {
    const localeJson = fs.readFileSync(path.join(LOCALE_DIR, `${locale}.json`), {
      encoding: "utf-8",
    });
    const localeObj = JSON.parse(localeJson);
    const localeStrs: { [key: string]: string } = flatten(localeObj);

    return localeStrs;
  }
});
Example #18
Source File: about.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("AboutComponent", () => {
  let component: AboutComponent;
  let fixture: ComponentFixture<AboutComponent>;
  let wowupService: WowUpService;
  let electronServiceSpy: any;
  let sessionService: SessionService;
  let patchNotesService: PatchNotesService;
  let dialogFactory: DialogFactory;
  let linkService: any;

  beforeEach(async () => {
    wowupService = jasmine.createSpyObj("WowUpService", [""]);
    electronServiceSpy = jasmine.createSpyObj("ElectronService", [""], {
      getVersionNumber: () => Promise.resolve("2.0.0"),
    });

    sessionService = jasmine.createSpyObj("SessionService", [""], {
      selectedHomeTab$: new BehaviorSubject(1),
    });

    linkService = jasmine.createSpyObj("LinkService", [""], {});
    patchNotesService = jasmine.createSpyObj("PatchNotesService", [""], {});
    dialogFactory = jasmine.createSpyObj("DialogFactory", [""], {});

    await TestBed.configureTestingModule({
      declarations: [AboutComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(AboutComponent, {
        set: {
          providers: [
            { provide: LinkService, useValue: linkService },
            { provide: WowUpService, useValue: wowupService },
            { provide: ElectronService, useValue: electronServiceSpy },
            { provide: SessionService, useValue: sessionService },
            { provide: PatchNotesService, useValue: patchNotesService },
            { provide: DialogFactory, useValue: dialogFactory },
          ],
        },
      })
      .compileComponents();

    fixture = TestBed.createComponent(AboutComponent);
    component = fixture.componentInstance;

    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #19
Source File: titlebar.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("TitlebarComponent", () => {
  let component: TitlebarComponent;
  let fixture: ComponentFixture<TitlebarComponent>;
  let electronServiceSpy: any;
  let wowUpServiceSpy: any;

  beforeEach(async () => {
    electronServiceSpy = jasmine.createSpyObj("ElectronService", ["on"], {
      windowMaximized$: new BehaviorSubject(false).asObservable(),
    });
    wowUpServiceSpy = jasmine.createSpyObj("WowUpService", [""], {
      currentTheme: "horde ofc",
    });

    await TestBed.configureTestingModule({
      declarations: [TitlebarComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(TitlebarComponent, {
        set: {
          providers: [
            OverlayContainer,
            { provide: ElectronService, useValue: electronServiceSpy },
            { provide: WowUpService, useValue: wowUpServiceSpy },
          ],
        },
      })
      .compileComponents();

    fixture = TestBed.createComponent(TitlebarComponent);
    component = fixture.componentInstance;

    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #20
Source File: footer.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
/** Fix icon warning? https://stackoverflow.com/a/62277810 */
describe("FooterComponent", () => {
  let fixture: ComponentFixture<FooterComponent>;
  let wowUpServiceSpy: WowUpService;
  let sessionServiceSpy: SessionService;
  let electronService: ElectronService;
  let linkService: LinkService;

  beforeEach(async () => {
    mockPreload();

    wowUpServiceSpy = jasmine.createSpyObj("WowUpService", [], {
      getApplicationVersion: () => Promise.resolve("TESTV"),
      wowupUpdateCheck$: new Subject<UpdateCheckResult>().asObservable(),
      wowupUpdateDownloaded$: new Subject<any>().asObservable(),
      wowupUpdateDownloadInProgress$: new Subject<boolean>().asObservable(),
    });

    sessionServiceSpy = jasmine.createSpyObj("SessionService", [""], {
      statusText$: new BehaviorSubject(""),
      pageContextText$: new BehaviorSubject(""),
      wowUpAccount$: new Subject(),
    });

    linkService = jasmine.createSpyObj("LinkService", [""], {});

    electronService = jasmine.createSpyObj("ElectronService", [""], {
      appUpdate$: new Subject(),
    });

    await TestBed.configureTestingModule({
      declarations: [FooterComponent, MatIcon],
      imports: [
        MatModule,
        NoopAnimationsModule,
        MatIconTestingModule,
        OverlayModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(FooterComponent, {
        set: {
          providers: [
            { provide: ElectronService, useValue: electronService },
            { provide: WowUpService, useValue: wowUpServiceSpy },
            { provide: SessionService, useValue: sessionServiceSpy },
            { provide: LinkService, useValue: linkService },
          ],
        },
      })
      .compileComponents();
  });

  it("should create", () => {
    fixture = TestBed.createComponent(FooterComponent);
    expect(fixture.componentInstance).toBeTruthy();
  });
});
Example #21
Source File: my-addons-addon-cell.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("MyAddonsAddonCellComponent", () => {
  let component: MyAddonsAddonCellComponent;
  let fixture: ComponentFixture<MyAddonsAddonCellComponent>;
  let sessionService: SessionService;

  beforeEach(async () => {
    sessionService = jasmine.createSpyObj("SessionService", [""], {
      myAddonsCompactVersion$: new BehaviorSubject(false),
    });

    await TestBed.configureTestingModule({
      declarations: [MyAddonsAddonCellComponent],
      imports: [
        MatModule,
        NoopAnimationsModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(MyAddonsAddonCellComponent, {
        set: {
          providers: [{ provide: SessionService, useValue: sessionService }],
        },
      })
      .compileComponents();

    fixture = TestBed.createComponent(MyAddonsAddonCellComponent);
    component = fixture.componentInstance;

    component.listItem = new AddonViewModel({
      name: "Test Tool",
      dependencies: [],
    } as Addon);

    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #22
Source File: my-addon-status-cell.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("MyAddonStatusCellComponent", () => {
  let component: MyAddonStatusCellComponent;
  let fixture: ComponentFixture<MyAddonStatusCellComponent>;
  let addonServiceSpy: AddonService;

  beforeEach(async () => {
    addonServiceSpy = jasmine.createSpyObj(
      "AddonService",
      {
        getAddons: Promise.resolve([]),
        backfillAddons: Promise.resolve(undefined),
      },
      {
        addonInstalled$: new Subject<AddonUpdateEvent>().asObservable(),
        addonRemoved$: new Subject<string>().asObservable(),
      }
    );

    await TestBed.configureTestingModule({
      declarations: [MyAddonStatusCellComponent],
      providers: [MatDialog],
      imports: [
        MatModule,
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(MyAddonStatusCellComponent, {
        set: {
          providers: [{ provide: AddonService, useValue: addonServiceSpy }],
        },
      })
      .compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(MyAddonStatusCellComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #23
Source File: install-from-url-dialog.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("InstallFromUrlDialogComponent", () => {
  console.log("InstallFromUrlDialogComponent");
  let component: InstallFromUrlDialogComponent;
  let fixture: ComponentFixture<InstallFromUrlDialogComponent>;
  let sessionServiceSpy: any;
  let addonServiceSpy: any;

  beforeEach(async () => {
    let testBed = TestBed.configureTestingModule({
      declarations: [InstallFromUrlDialogComponent],
      imports: [
        MatModule,
        HttpClientModule,
        BrowserAnimationsModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    });

    testBed = overrideIconModule(testBed).overrideComponent(InstallFromUrlDialogComponent, {
      set: {
        providers: [
          DownloadCountPipe,
          { provide: MatDialogRef, useValue: {} },
          { provide: AddonService, useValue: addonServiceSpy },
          { provide: SessionService, useValue: sessionServiceSpy },
          { provide: IconService },
        ],
      },
    });

    await testBed.compileComponents();

    fixture = TestBed.createComponent(InstallFromUrlDialogComponent);
    component = fixture.componentInstance;

    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #24
Source File: install-from-protocol-dialog.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("InstallFromProtocolDialogComponent", () => {
  let component: InstallFromProtocolDialogComponent;
  let fixture: ComponentFixture<InstallFromProtocolDialogComponent>;
  let addonService: AddonService;
  let sessionService: SessionService;
  let warcraftInstallationService: WarcraftInstallationService;
  let dialogModel: InstallFromProtocolDialogComponentData;

  beforeEach(async () => {
    addonService = jasmine.createSpyObj(
      "AddonService",
      {
        getAddonForProtocol: () => Promise.resolve(undefined),
      },
      {}
    );

    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(() => {
    fixture = TestBed.createComponent(InstallFromProtocolDialogComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #25
Source File: funding-button.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("FundingButtonComponent", () => {
  let component: FundingButtonComponent;
  let fixture: ComponentFixture<FundingButtonComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [FundingButtonComponent, MatIcon],
      imports: [
        MatModule,
        HttpClientModule,
        NoopAnimationsModule,
        MatIconTestingModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
      schemas: [CUSTOM_ELEMENTS_SCHEMA],
    }).compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(FundingButtonComponent);
    component = fixture.componentInstance;
    component.funding = {
      platform: "TEST",
      url: "TEST",
    };
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #26
Source File: addon-update-button.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("AddonUpdateButtonComponent", () => {
  let addonServiceSpy: AddonService;
  let analyticsServiceSpy: AnalyticsService;

  beforeEach(async () => {
    addonServiceSpy = jasmine.createSpyObj("AddonService", [""], {
      addonInstalled$: new Subject<AddonUpdateEvent>().asObservable(),
    });

    await TestBed.configureTestingModule({
      declarations: [AddonUpdateButtonComponent, ProgressButtonComponent],
      providers: [MatDialog, ElectronService],
      imports: [
        MatModule,
        HttpClientModule,
        BrowserAnimationsModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(AddonUpdateButtonComponent, {
        set: {
          providers: [
            MatDialog,
            { provide: AddonService, useValue: addonServiceSpy },
            { provide: AnalyticsService, useValue: analyticsServiceSpy },
          ],
        },
      })
      .compileComponents();
  });

  it("should create", () => {
    const fixture = TestBed.createComponent(AddonUpdateButtonComponent);
    expect(fixture.componentInstance).toBeTruthy();
  });
});
Example #27
Source File: addon-install-button.component.spec.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
describe("AddonInstallButtonComponent", () => {
  let addonServiceSpy: AddonService;
  let sessionServiceSpy: SessionService;

  beforeEach(async () => {
    addonServiceSpy = jasmine.createSpyObj(
      "AddonService",
      {
        isInstalled: () => false,
      },
      {
        addonInstalled$: new Subject<AddonUpdateEvent>().asObservable(),
      }
    );
    sessionServiceSpy = jasmine.createSpyObj("SessionService", ["getSelectedClientType"], {
      selectedClientType: WowClientType.Retail,
    });

    await TestBed.configureTestingModule({
      declarations: [AddonInstallButtonComponent, ProgressButtonComponent],
      imports: [
        HttpClientModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(AddonInstallButtonComponent, {
        set: {
          providers: [
            { provide: AddonService, useValue: addonServiceSpy },
            { provide: SessionService, useValue: sessionServiceSpy },
          ],
        },
      })
      .compileComponents();
  });

  it("should create", () => {
    const fixture = TestBed.createComponent(AddonInstallButtonComponent);
    expect(fixture.componentInstance).toBeTruthy();
  });
});
Example #28
Source File: app.module.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
@NgModule({
  declarations: [AppComponent, TitlebarComponent, FooterComponent, HorizontalTabsComponent, VerticalTabsComponent],
  imports: [
    BrowserModule,
    FormsModule,
    HttpClientModule,
    HomeModule,
    AppRoutingModule,
    DirectiveModule,
    MatModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: httpLoaderFactory,
        deps: [HttpClient],
      },
      compiler: {
        provide: TranslateCompiler,
        useClass: TranslateMessageFormatCompiler,
      },
    }),
    BrowserAnimationsModule,
    GalleryModule,
    CommonUiModule,
  ],
  providers: [
    {
      provide: APP_INITIALIZER,
      useFactory: initializeApp,
      deps: [
        WowUpService,
        WowUpApiService,
        AddonService,
        WarcraftInstallationService,
        IconService,
        AddonProviderFactory,
      ],
      multi: true,
    },
    {
      provide: HTTP_INTERCEPTORS,
      useClass: DefaultHeadersInterceptor,
      multi: true,
    },
    {
      provide: ErrorHandler,
      useClass: ErrorHandlerInterceptor,
      deps: [AnalyticsService],
    },
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}
Example #29
Source File: app.component.spec.ts    From WowUp with GNU General Public License v3.0 4 votes vote down vote up
describe("AppComponent", () => {
  let addonServiceSpy: AddonService;
  let electronServiceSpy: ElectronService;
  let wowUpServiceSpy: WowUpService;
  let sessionServiceSpy: SessionService;
  let fileServiceSpy: FileService;
  let analyticsServiceSpy: AnalyticsService;
  let preferenceStorageSpy: PreferenceStorageService;
  let wowUpAddonServiceSpy: WowUpAddonService;
  let warcraftInstallationService: WarcraftInstallationService;
  let zoomService: ZoomService;
  let addonProviderService: any;

  beforeEach(async () => {
    wowUpAddonServiceSpy = jasmine.createSpyObj(
      "WowUpAddonService",
      ["updateForClientType", "updateForAllClientTypes"],
      {
        persistUpdateInformationToWowUpAddon: () => {},
      }
    );

    addonServiceSpy = jasmine.createSpyObj("AddonService", ["processAutoUpdates", "syncAllClients"], {
      syncError$: new Subject(),
    });

    addonProviderService = jasmine.createSpyObj(
      "AddonProviderFactory",
      {
        getAdRequiredProviders: () => [],
      },
      {}
    );

    warcraftInstallationService = jasmine.createSpyObj("WarcraftInstallationService", [""], {
      wowInstallations$: new Subject(),
    });

    zoomService = jasmine.createSpyObj("ZoomService", [""], {});

    electronServiceSpy = jasmine.createSpyObj("ElectronService", ["invoke", "on", "off"], {
      appOptions: { quit: null },
      getAppOptions: () => Promise.resolve({}),
      powerMonitor$: new Observable(),
      appUpdate$: new Observable(),
      ipcRenderer: {
        on: () => {},
      },
    });
    wowUpServiceSpy = jasmine.createSpyObj("WowUpService", [""], {
      preferenceChange$: new Subject<PreferenceChange>().asObservable(),
    });
    sessionServiceSpy = jasmine.createSpyObj("SessionService", ["autoUpdateComplete"], {
      adSpace$: new BehaviorSubject(false),
    });
    fileServiceSpy = jasmine.createSpyObj("FileService", [""]);
    analyticsServiceSpy = jasmine.createSpyObj("AnalyticsService", ["trackStartup"]);
    preferenceStorageSpy = jasmine.createSpyObj("PreferenceStorageService", ["get"], {});

    await TestBed.configureTestingModule({
      declarations: [AppComponent, AnimatedLogoComponent],
      providers: [MatDialog, ElectronService],
      imports: [
        OverlayModule,
        RouterTestingModule,
        HttpClientModule,
        MatModule,
        NoopAnimationsModule,
        TranslateModule.forRoot({
          loader: {
            provide: TranslateLoader,
            useFactory: httpLoaderFactory,
            deps: [HttpClient],
          },
          compiler: {
            provide: TranslateCompiler,
            useClass: TranslateMessageFormatCompiler,
          },
        }),
      ],
    })
      .overrideComponent(AppComponent, {
        set: {
          providers: [
            MatDialog,
            OverlayContainer,
            { provide: AddonService, useValue: addonServiceSpy },
            { provide: ElectronService, useValue: electronServiceSpy },
            { provide: WowUpService, useValue: wowUpServiceSpy },
            { provide: SessionService, useValue: sessionServiceSpy },
            { provide: FileService, useValue: fileServiceSpy },
            { provide: AnalyticsService, useValue: analyticsServiceSpy },
            { provide: PreferenceStorageService, useValue: preferenceStorageSpy },
            { provide: WowUpAddonService, useValue: wowUpAddonServiceSpy },
            { provide: WarcraftInstallationService, useValue: warcraftInstallationService },
            { provide: ZoomService, useValue: zoomService },
            { provide: AddonProviderFactory, useValue: addonProviderService },
          ],
        },
      })
      .compileComponents();
  });

  it("should create", () => {
    const fixture = TestBed.createComponent(AppComponent);
    expect(fixture.componentInstance).toBeTruthy();
  });
});