fix: Fixed test units
This commit is contained in:
@@ -12,22 +12,24 @@ import { of } from 'rxjs';
|
||||
describe('AppViewComponent', () => {
|
||||
let component: AppViewComponent;
|
||||
let fixture: ComponentFixture<AppViewComponent>;
|
||||
let authClient: jasmine.SpyObj<AuthClient>;
|
||||
|
||||
beforeEach(() => {
|
||||
const authSpy = jasmine.createSpyObj('AuthClient', ['check'])
|
||||
const pushSpy = jasmine.createSpyObj('SwPush', ['requestSubscription'])
|
||||
const updatesSpy = jasmine.createSpyObj('UpdatesService', ['postNotif'])
|
||||
const updatesSpy = jasmine.createSpyObj('UpdatesService', {
|
||||
newsCheck: of()
|
||||
})
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [AppViewComponent],
|
||||
providers: [{provide: AuthClient, useValue: authSpy},
|
||||
{provide: SwPush, useValue: pushSpy},
|
||||
{provide: UpdatesService, useValue: updatesSpy}],
|
||||
providers: [
|
||||
{provide: AuthClient, useValue: authSpy},
|
||||
{provide: SwPush, useValue: pushSpy},
|
||||
{provide: UpdatesService, useValue: updatesSpy}
|
||||
],
|
||||
imports: [MatTabsModule, RouterModule.forRoot([]), MatIconModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(AppViewComponent);
|
||||
component = fixture.componentInstance;
|
||||
authClient = TestBed.inject(AuthClient) as jasmine.SpyObj<AuthClient>
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
@@ -14,13 +14,17 @@ import { MatInputModule } from '@angular/material/input';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatBottomSheet, MatBottomSheetModule } from '@angular/material/bottom-sheet';
|
||||
import { of } from 'rxjs';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
|
||||
describe('MenuComponent', () => {
|
||||
let component: MenuComponent;
|
||||
let fixture: ComponentFixture<MenuComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
const updatesSpy = jasmine.createSpyObj('UpdatesService', ['getMenu'])
|
||||
const updatesSpy = jasmine.createSpyObj('UpdatesService', {
|
||||
getMenu: of()
|
||||
})
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ MenuComponent, DateSelectorComponent],
|
||||
providers: [
|
||||
@@ -30,7 +34,17 @@ describe('MenuComponent', () => {
|
||||
{provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS},
|
||||
{provide: MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: {useUtc: true}},
|
||||
],
|
||||
imports: [MatIconModule, MatFormFieldModule, MatDatepickerModule, MatCardModule, ReactiveFormsModule, MatInputModule, BrowserAnimationsModule, MatBottomSheetModule]
|
||||
imports: [
|
||||
MatIconModule,
|
||||
MatFormFieldModule,
|
||||
MatDatepickerModule,
|
||||
MatCardModule,
|
||||
ReactiveFormsModule,
|
||||
MatInputModule,
|
||||
BrowserAnimationsModule,
|
||||
MatBottomSheetModule,
|
||||
MatProgressSpinnerModule
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NewsComponent } from './news.component';
|
||||
import { UpdatesService } from 'src/app/services/updates.service';
|
||||
import { of } from 'rxjs';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { LocalStorageService } from 'src/app/services/local-storage.service';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
|
||||
describe('NewsComponent', () => {
|
||||
let component: NewsComponent;
|
||||
@@ -12,11 +16,20 @@ describe('NewsComponent', () => {
|
||||
const updatesMock = jasmine.createSpyObj('UpdatesService', {
|
||||
getNews: of()
|
||||
})
|
||||
const lsMock = {
|
||||
news: []
|
||||
}
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ NewsComponent ],
|
||||
providers: [
|
||||
{provide: UpdatesService, useValue: updatesMock}
|
||||
{provide: UpdatesService, useValue: updatesMock},
|
||||
{provide: LocalStorageService, useValue: lsMock}
|
||||
],
|
||||
imports: [
|
||||
MatProgressSpinnerModule,
|
||||
NoopAnimationsModule,
|
||||
MatCardModule
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@@ -1,14 +1,28 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { NotifDialogComponent } from './notif-dialog.component';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { UpdatesService } from 'src/app/services/updates.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('NotifDialogComponent', () => {
|
||||
let component: NotifDialogComponent;
|
||||
let fixture: ComponentFixture<NotifDialogComponent>;
|
||||
|
||||
|
||||
beforeEach(async () => {
|
||||
const uMock = jasmine.createSpyObj<UpdatesService>("UpdatesService", {
|
||||
postInfoAck: of()
|
||||
})
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [NotifDialogComponent]
|
||||
declarations: [NotifDialogComponent],
|
||||
providers: [
|
||||
{provide: MAT_DIALOG_DATA, useValue: {message: "Test"}},
|
||||
{provide: MatDialogRef, useValue: {}},
|
||||
{provide: UpdatesService, useValue: uMock}
|
||||
],
|
||||
imports: [
|
||||
MatDialogModule
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AboutComponent } from './about.component';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
|
||||
describe('AboutComponent', () => {
|
||||
let component: AboutComponent;
|
||||
@@ -8,7 +10,11 @@ describe('AboutComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [AboutComponent]
|
||||
declarations: [AboutComponent],
|
||||
imports: [
|
||||
MatDialogModule,
|
||||
MatListModule
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@@ -1,14 +1,37 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CleanComponent } from './clean.component';
|
||||
import { UpdatesService } from 'src/app/services/updates.service';
|
||||
import { of } from 'rxjs';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatDatepicker } from '@angular/material/datepicker';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import * as moment from 'moment';
|
||||
|
||||
@Component({selector: "app-date-selector", template: ''})
|
||||
class DateSelectorStub {
|
||||
@Input() date: moment.Moment = moment.utc().startOf('day');
|
||||
@Output() dateChange = new EventEmitter<moment.Moment>();
|
||||
@Input() filter: (date: moment.Moment | null) => boolean = () => true
|
||||
}
|
||||
|
||||
describe('CleanComponent', () => {
|
||||
let component: CleanComponent;
|
||||
let fixture: ComponentFixture<CleanComponent>;
|
||||
let updates: jasmine.SpyObj<UpdatesService>
|
||||
|
||||
beforeEach(async () => {
|
||||
updates = jasmine.createSpyObj<UpdatesService>("UpdatesService", {
|
||||
getClean: of()
|
||||
})
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [CleanComponent]
|
||||
declarations: [CleanComponent, DateSelectorStub],
|
||||
providers: [
|
||||
{provide: UpdatesService, useValue: updates}
|
||||
],
|
||||
imports: [MatDialogModule, MatIconModule, MatFormFieldModule, MatDatepicker]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ExtraComponent } from './extra.component';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
|
||||
describe('ExtraComponent', () => {
|
||||
let component: ExtraComponent;
|
||||
@@ -8,7 +10,11 @@ describe('ExtraComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ExtraComponent]
|
||||
declarations: [ExtraComponent],
|
||||
imports: [
|
||||
MatDialogModule,
|
||||
MatListModule
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@@ -1,20 +1,37 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MatInputHarness } from '@angular/material/input/testing'
|
||||
import { RedirectComponent } from './redirect.component';
|
||||
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AuthClient } from 'src/app/services/auth.client';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
describe('RedirectComponent', () => {
|
||||
let component: RedirectComponent;
|
||||
let fixture: ComponentFixture<RedirectComponent>;
|
||||
let loader: HarnessLoader
|
||||
let authMock
|
||||
|
||||
beforeEach(async () => {
|
||||
authMock = jasmine.createSpyObj<AuthClient>("AuthClient", {}, {redirect: ''})
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [RedirectComponent]
|
||||
declarations: [RedirectComponent],
|
||||
providers: [
|
||||
{provide: MatDialogRef, useValue: {}},
|
||||
{provide: AuthClient, useValue: authMock}
|
||||
],
|
||||
imports: [MatDialogModule, MatFormFieldModule, MatInputModule, FormsModule, NoopAnimationsModule]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(RedirectComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
loader = TestbedHarnessEnvironment.loader(fixture)
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { KeyComponent } from './key.component';
|
||||
import { UpdatesService } from 'src/app/services/updates.service';
|
||||
import { of } from 'rxjs';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
describe('KeyComponent', () => {
|
||||
let component: KeyComponent;
|
||||
let fixture: ComponentFixture<KeyComponent>;
|
||||
let uMock: jasmine.SpyObj<UpdatesService>
|
||||
|
||||
beforeEach(async () => {
|
||||
uMock = jasmine.createSpyObj<UpdatesService>("UpdatesService", {
|
||||
getKeys: of()
|
||||
})
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [KeyComponent]
|
||||
declarations: [KeyComponent],
|
||||
providers: [
|
||||
{provide: UpdatesService, useValue: uMock}
|
||||
],
|
||||
imports: [MatDialogModule, MatIconModule]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
@@ -3,23 +3,30 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { PersonalComponent } from './personal.component';
|
||||
import { AuthClient } from 'src/app/services/auth.client';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { SwUpdate } from '@angular/service-worker';
|
||||
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { AppUpdateService } from 'src/app/services/app-update.service';
|
||||
import { of } from 'rxjs';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
describe('PersonalComponent', () => {
|
||||
let component: PersonalComponent;
|
||||
let fixture: ComponentFixture<PersonalComponent>;
|
||||
let auMock: jasmine.SpyObj<AppUpdateService>
|
||||
|
||||
beforeEach(() => {
|
||||
auMock = jasmine.createSpyObj("aumock", {
|
||||
checkForUpdate: of()
|
||||
})
|
||||
const authMock = jasmine.createSpyObj('AuthClient', ['s'])
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PersonalComponent],
|
||||
providers: [
|
||||
{provide: AuthClient, useValue: authMock},
|
||||
{provide: AppUpdateService, useValue: auMock}
|
||||
],
|
||||
imports: [MatDialogModule, MatSnackBarModule, MatListModule, BrowserAnimationsModule]
|
||||
imports: [MatDialogModule, MatSnackBarModule, MatListModule, NoopAnimationsModule, MatIconModule]
|
||||
});
|
||||
fixture = TestBed.createComponent(PersonalComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { StartComponent } from './start.component';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
|
||||
describe('StartComponent', () => {
|
||||
let component: StartComponent;
|
||||
@@ -8,7 +10,11 @@ describe('StartComponent', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [StartComponent]
|
||||
declarations: [StartComponent],
|
||||
imports: [
|
||||
RouterModule.forRoot([]),
|
||||
MatListModule
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user