Skip to content

Commit

Permalink
chore: Provide EditorFacadeMock to unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Angi-Kinas committed Dec 3, 2024
1 parent b7e25d3 commit b7b4c35
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { MatDialog, MatDialogRef } from '@angular/material/dialog'
import { OnlineLinkResource } from '@geonetwork-ui/common/domain/model/record'
import { ModalDialogComponent } from '@geonetwork-ui/ui/layout'
import { ChangeDetectorRef } from '@angular/core'
import { EditorFacade } from '../../../../+state/editor.facade'

let uploadSubject: Subject<any>

Expand All @@ -38,6 +39,10 @@ export class MatDialogMock {
}))
}

class EditorFacadeMock {
alreadySavedOnce$ = new BehaviorSubject(false)
}

describe('FormFieldOnlineLinkResourcesComponent', () => {
let component: FormFieldOnlineLinkResourcesComponent
let fixture: ComponentFixture<FormFieldOnlineLinkResourcesComponent>
Expand Down Expand Up @@ -65,6 +70,7 @@ describe('FormFieldOnlineLinkResourcesComponent', () => {
detectChanges: jest.fn(),
}),
MockProvider(MatDialog, MatDialogMock, 'useClass'),
MockProvider(EditorFacade, EditorFacadeMock, 'useClass'),
],
}).compileComponents()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'
import { TranslateModule } from '@ngx-translate/core'
import { FormFieldOnlineResourcesComponent } from './form-field-online-resources.component'
import { MockBuilder, MockProvider } from 'ng-mocks'
import { Subject } from 'rxjs'
import { BehaviorSubject, Subject } from 'rxjs'
import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.service.interface'
import { NotificationsService } from '@geonetwork-ui/feature/notifications'
import { MatDialog, MatDialogRef } from '@angular/material/dialog'
import { EditorFacade } from '../../../../+state/editor.facade'

let uploadSubject: Subject<any>
class PlatformServiceInterfaceMock {
Expand All @@ -21,6 +22,9 @@ export class MatDialogMock {
afterClosed: () => this._subject,
}))
}
class EditorFacadeMock {
alreadySavedOnce$ = new BehaviorSubject(false)
}

describe('FormFieldOnlineResourcesComponent', () => {
let component: FormFieldOnlineResourcesComponent
Expand All @@ -42,6 +46,7 @@ describe('FormFieldOnlineResourcesComponent', () => {
MockProvider(NotificationsService),
MockProvider(MatDialogRef),
MockProvider(MatDialog, MatDialogMock, 'useClass'),
MockProvider(EditorFacade, EditorFacadeMock, 'useClass'),
],
}).compileComponents()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
PlatformServiceInterface,
RecordAttachment,
} from '@geonetwork-ui/common/domain/platform.service.interface'
import { EditorFacade } from '../../../../+state/editor.facade'

let uploadSubject: Subject<any>

Expand All @@ -26,6 +27,10 @@ class PlatformServiceInterfaceMock {
getRecordAttachments = jest.fn(() => recordAttachments)
}

class EditorFacadeMock {
alreadySavedOnce$ = new BehaviorSubject(false)
}

describe('FormFieldOverviewsComponent', () => {
let component: FormFieldOverviewsComponent
let fixture: ComponentFixture<FormFieldOverviewsComponent>
Expand All @@ -46,6 +51,7 @@ describe('FormFieldOverviewsComponent', () => {
'useClass'
),
MockProvider(NotificationsService),
MockProvider(EditorFacade, EditorFacadeMock, 'useClass'),
],
}).compileComponents()

Expand Down

0 comments on commit b7b4c35

Please sign in to comment.