Skip to content

Commit

Permalink
fix(me): fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Sep 12, 2023
1 parent 09f84cc commit 5a16777
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
4 changes: 4 additions & 0 deletions apps/metadata-editor-e2e/src/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ describe('dashboard', () => {
.then((list) => {
newFirstItem = list.trim()
expect(newFirstItem).not.to.equal(originalFirstItem)
cy.url().should(
'include',
'sort=resourceTitleObject.default.keyword'
)
})
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { DashboardPageComponent } from './dashboard-page.component'
import { CommonModule } from '@angular/common'
import { SearchService } from '@geonetwork-ui/feature/search'

class SearchServiceMock {
setSortBy = jest.fn()
}

describe('DashboardPageComponent', () => {
let component: DashboardPageComponent
let fixture: ComponentFixture<DashboardPageComponent>
let searchService: SearchService

beforeEach(async () => {
await TestBed.overrideComponent(DashboardPageComponent, {
set: {
imports: [CommonModule],
providers: [],
},
}).compileComponents()
await TestBed.configureTestingModule({
providers: [
{
provide: SearchService,
useClass: SearchServiceMock,
},
],
})
.overrideComponent(DashboardPageComponent, {
set: {
imports: [CommonModule],
providers: [],
},
})
.compileComponents()

fixture = TestBed.createComponent(DashboardPageComponent)
searchService = TestBed.inject(SearchService)
component = fixture.componentInstance
fixture.detectChanges()
})

it('should create', () => {
expect(component).toBeTruthy()
})
it('orders the completion column', () => {
expect(searchService.setSortBy).toHaveBeenCalledWith(['desc', 'changeDate'])
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@ describe('RecordsListComponent', () => {
expect(pagination.currentPage).toEqual(currentPage)
expect(pagination.totalPages).toEqual(totalPages)
})
it('orders the completion column', () => {
expect(searchService.setSortBy).toHaveBeenCalledWith([
'desc',
'changeDate',
])
})
describe('when click on a record', () => {
beforeEach(() => {
table.recordSelect.emit({ uniqueIdentifier: 123 })
Expand Down

0 comments on commit 5a16777

Please sign in to comment.