Skip to content

Commit

Permalink
Fix unit test record form
Browse files Browse the repository at this point in the history
  • Loading branch information
Angi-Kinas committed Aug 7, 2024
1 parent 4934e70 commit 301e7a3
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,23 +1,51 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { EditorFacade } from '../../+state/editor.facade'
import { RecordFormComponent } from './record-form.component'
import { EffectsModule } from '@ngrx/effects'
import { StoreModule } from '@ngrx/store'
import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface'
import { Gn4Converter } from '@geonetwork-ui/api/metadata-converter'
import { of } from 'rxjs'

class EditorFacadeMock {
updateRecordField = jest.fn()
}

class Gn4MetadataMapperMock {
readRecords = jest.fn((records) =>
Promise.all(records.map((r) => this.readRecord(r)))
)
readRecord = jest.fn((record) => Promise.resolve(record))
}

class PlatformServiceInterfaceMock {
getMe = jest.fn(() => of({}))
}

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

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [RecordFormComponent],
imports: [
RecordFormComponent,
EffectsModule.forRoot(),
StoreModule.forRoot({}),
],
providers: [
{
provide: EditorFacade,
useClass: EditorFacadeMock,
},
{
provide: PlatformServiceInterface,
useClass: PlatformServiceInterfaceMock,
},
{
provide: Gn4Converter,
useClass: Gn4MetadataMapperMock,
},
],
}).compileComponents()

Expand Down

0 comments on commit 301e7a3

Please sign in to comment.