Skip to content

Commit

Permalink
test(my-records): adapt unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Sep 20, 2024
1 parent e94cf18 commit e8da379
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ export class AllRecordsComponent implements OnInit {
) {}

ngOnInit(): void {
this.searchFacade.setConfigRequestFields(allSearchFields).setPageSize(15)
this.searchFacade.setConfigRequestFields(allSearchFields)
this.searchFacade.setPageSize(15)
}

createRecord() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { PlatformServiceInterface } from '@geonetwork-ui/common/domain/platform.
import { MockBuilder, MockInstance, MockProviders } from 'ng-mocks'
import { ActivatedRoute, Router } from '@angular/router'
import { TranslateModule } from '@ngx-translate/core'
import { allSearchFields } from '../all-records/all-records.component'

describe('MyRecordsComponent', () => {
MockInstance.scope()
Expand Down Expand Up @@ -106,11 +107,16 @@ describe('MyRecordsComponent', () => {
expect(component).toBeTruthy()
})

describe('filters', () => {
it('clears filters on init', () => {
expect(searchFacade.resetSearch).toHaveBeenCalled()
describe('filters on init', () => {
it('sets search fields', () => {
expect(searchFacade.setConfigRequestFields).toHaveBeenCalledWith(
allSearchFields
)
})
it('sets page size', () => {
expect(searchFacade.setPageSize).toHaveBeenCalledWith(15)
})
it('Update filters on init', () => {
it('updates filters with owner', () => {
expect(searchFacade.updateFilters).toHaveBeenCalledWith({
owner: user.id,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export class MyRecordsComponent implements OnInit, OnDestroy {
) {}

ngOnInit() {
this.searchFacade.setConfigRequestFields(allSearchFields).setPageSize(15)
this.searchFacade.setConfigRequestFields(allSearchFields)
this.searchFacade.setPageSize(15)

this.sub = this.platformService.getMe().subscribe((user) => {
this.ownerId = user.id
Expand Down

0 comments on commit e8da379

Please sign in to comment.