Skip to content

Commit

Permalink
remove logs in a complicated way
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Sep 4, 2024
1 parent aeb4c99 commit ed4f295
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 6 deletions.
63 changes: 62 additions & 1 deletion src/app/register/components/step-b/step-b.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,80 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'

import { StepBComponent } from './step-b.component'

import { CUSTOM_ELEMENTS_SCHEMA, forwardRef } from '@angular/core'
import {
NG_VALUE_ACCESSOR,
ReactiveFormsModule,
UntypedFormControl,
UntypedFormGroup,
} from '@angular/forms'
import { FormPasswordComponent } from 'src/app/register2/components/form-password/form-password.component'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { RouterTestingModule } from '@angular/router/testing'
import { WINDOW_PROVIDERS } from 'src/app/cdk/window/window.service'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
import { ErrorHandlerService } from 'src/app/core/error-handler/error-handler.service'
import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service'
import { Overlay } from '@angular/cdk/overlay'
import { MatLegacySnackBar as MatSnackBar } from '@angular/material/legacy-snack-bar'
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'

import { Component } from '@angular/core'
import { ControlValueAccessor } from '@angular/forms'

@Component({
selector: 'app-form-notifications',
template: '<div></div>',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MockFormNotificationsComponent),
multi: true,
},
],
})
export class MockFormNotificationsComponent implements ControlValueAccessor {
writeValue(): void {}
registerOnChange(fn: () => void): void {}
registerOnTouched(fn: () => void): void {}
}

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

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [StepBComponent],
imports: [
ReactiveFormsModule,
HttpClientTestingModule,
RouterTestingModule,
],
declarations: [
StepBComponent,
FormPasswordComponent,
MockFormNotificationsComponent,
],
providers: [
WINDOW_PROVIDERS,
PlatformInfoService,
ErrorHandlerService,
MatSnackBar,
MatDialog,
SnackbarService,
Overlay,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents()
})

beforeEach(() => {
fixture = TestBed.createComponent(StepBComponent)
component = fixture.componentInstance
component.formGroup = new UntypedFormGroup({
password: new UntypedFormControl(''),
sendOrcidNews: new UntypedFormControl(''),
})
fixture.detectChanges()
})

Expand Down
99 changes: 98 additions & 1 deletion src/app/register/components/step-c/step-c.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,116 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'

import { StepCComponent } from './step-c.component'

import { Component, CUSTOM_ELEMENTS_SCHEMA, forwardRef } from '@angular/core'
import {
ControlValueAccessor,
NG_VALUE_ACCESSOR,
ReactiveFormsModule,
UntypedFormControl,
UntypedFormGroup,
} from '@angular/forms'
import { FormVisibilityComponent } from '../form-visibility/form-visibility.component'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { RouterTestingModule } from '@angular/router/testing'
import { WINDOW_PROVIDERS } from 'src/app/cdk/window/window.service'
import { PlatformInfoService } from 'src/app/cdk/platform-info/platform-info.service'
import { ErrorHandlerService } from 'src/app/core/error-handler/error-handler.service'
import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service'
import { MatLegacySnackBar as MatSnackBar } from '@angular/material/legacy-snack-bar'
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog'
import { Overlay } from '@angular/cdk/overlay'
import { FormTermsComponent } from '../form-terms/form-terms.component'
import { FormAntiRobotsComponent } from '../form-anti-robots/form-anti-robots.component'

@Component({
selector: 'app-form-visibility',
template: '<div></div>',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MockFormVisibilityComponent),
multi: true,
},
],
})
export class MockFormVisibilityComponent implements ControlValueAccessor {
writeValue(): void {}
registerOnChange(fn: () => void): void {}
registerOnTouched(fn: () => void): void {}
}

@Component({
selector: 'app-form-terms',
template: '<div></div>',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MockFormTermsComponent),
multi: true,
},
],
})
export class MockFormTermsComponent implements ControlValueAccessor {
writeValue(): void {}
registerOnChange(fn: () => void): void {}
registerOnTouched(fn: () => void): void {}
}

@Component({
selector: 'app-form-anti-robots',
template: '<div></div>',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MockFormAntiRobotsComponent),
multi: true,
},
],
})
export class MockFormAntiRobotsComponent implements ControlValueAccessor {
writeValue(): void {}
registerOnChange(fn: () => void): void {}
registerOnTouched(fn: () => void): void {}
}

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

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [StepCComponent],
imports: [
ReactiveFormsModule,
HttpClientTestingModule,
RouterTestingModule,
],
declarations: [
StepCComponent,
MockFormVisibilityComponent,
MockFormTermsComponent,
MockFormAntiRobotsComponent,
],
providers: [
WINDOW_PROVIDERS,
PlatformInfoService,
ErrorHandlerService,
MatSnackBar,
MatDialog,
SnackbarService,
Overlay,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents()
})

beforeEach(() => {
fixture = TestBed.createComponent(StepCComponent)
component = fixture.componentInstance
component.formGroup = new UntypedFormGroup({
activitiesVisibilityDefault: new UntypedFormControl(''),
termsOfUse: new UntypedFormControl(''),
captcha: new UntypedFormControl(''),
})
fixture.detectChanges()
})

Expand Down
44 changes: 43 additions & 1 deletion src/app/register2/components/step-c/step-c.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,61 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'

import { StepCComponent } from './step-c.component'

import { Component, CUSTOM_ELEMENTS_SCHEMA, forwardRef } from '@angular/core'
import {
ControlValueAccessor,
NG_VALUE_ACCESSOR,
ReactiveFormsModule,
UntypedFormControl,
UntypedFormGroup,
} from '@angular/forms'
import { HttpClientModule } from '@angular/common/http'
import { RouterTestingModule } from '@angular/router/testing'
import { WINDOW_PROVIDERS } from 'src/app/cdk/window'
import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service'
import { MatLegacySnackBarModule } from '@angular/material/legacy-snack-bar'

@Component({
selector: 'app-form-visibility',
template: '<div></div>',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MockFormVisibilityComponent),
multi: true,
},
],
})
export class MockFormVisibilityComponent implements ControlValueAccessor {
writeValue(): void {}
registerOnChange(fn: () => void): void {}
registerOnTouched(fn: () => void): void {}
}

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

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [StepCComponent],
imports: [
ReactiveFormsModule,
HttpClientModule,
RouterTestingModule,
MatLegacySnackBarModule,
],
declarations: [StepCComponent, MockFormVisibilityComponent],
providers: [WINDOW_PROVIDERS, SnackbarService],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents()
})

beforeEach(() => {
fixture = TestBed.createComponent(StepCComponent)
component = fixture.componentInstance
component.formGroup = new UntypedFormGroup({
activitiesVisibilityDefault: new UntypedFormControl(),
})
fixture.detectChanges()
})

Expand Down
35 changes: 34 additions & 1 deletion src/app/register2/components/step-c2/step-c2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,52 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'

import { StepC2Component } from './step-c2.component'

import { Component, CUSTOM_ELEMENTS_SCHEMA, forwardRef } from '@angular/core'
import {
ControlValueAccessor,
NG_VALUE_ACCESSOR,
ReactiveFormsModule,
UntypedFormControl,
UntypedFormGroup,
} from '@angular/forms'

@Component({
selector: 'app-form-current-employment',
template: '<div></div>',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => MockFormCurrentEmploymentComponent),
multi: true,
},
],
})
export class MockFormCurrentEmploymentComponent
implements ControlValueAccessor
{
writeValue(): void {}
registerOnChange(fn: () => void): void {}
registerOnTouched(fn: () => void): void {}
}

describe('StepCComponent', () => {
let component: StepC2Component
let fixture: ComponentFixture<StepC2Component>

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [StepC2Component],
imports: [ReactiveFormsModule],
declarations: [StepC2Component, MockFormCurrentEmploymentComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents()
})

beforeEach(() => {
fixture = TestBed.createComponent(StepC2Component)
component = fixture.componentInstance
component.formGroup = new UntypedFormGroup({
affiliations: new UntypedFormControl(''),
})
fixture.detectChanges()
})

Expand Down
Loading

0 comments on commit ed4f295

Please sign in to comment.