Skip to content

Commit

Permalink
feat(geom-filter): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fgravin committed Nov 29, 2023
1 parent 650eab0 commit 69c9d3f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 39 additions & 0 deletions libs/feature/search/src/lib/state/effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,45 @@ describe('Effects', () => {
})
)
})
describe('when geometry is broken', () => {
beforeEach(() => {
effects['filterGeometry$'] = of({
type: 'Polygon',
coordinates: [[]],
})
effects = TestBed.inject(SearchEffects)
actions$ = of(new RequestMoreResults('main'))
})
it('skips the geometry in the search', async () => {
await firstValueFrom(effects.loadResults$)
expect(repository.search).toHaveBeenCalledWith(
expect.not.objectContaining({
filterGeometry: { type: 'Polygon', coordinates: [[]] },
})
)
})
})
describe('when geometry is invalid', () => {
beforeEach(() => {
effects['filterGeometry$'] = of({
type: 'Polygon',
coordinates: [
[0, 1],
[0, 1],
],
}) as any
effects = TestBed.inject(SearchEffects)
actions$ = of(new RequestMoreResults('main'))
})
it('skips the geometry in the search', async () => {
await firstValueFrom(effects.loadResults$)
expect(repository.search).toHaveBeenCalledWith(
expect.not.objectContaining({
filterGeometry: { type: 'Polygon', coordinates: [[]] },
})
)
})
})
})
describe('when useSpatialFilter is disabled', () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion libs/feature/search/src/lib/state/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class SearchEffects {
map((geom) => [state, favorites, geom]),
catchError((e) => {
return of([state, favorites, null])
}) // silently opt out of spatial filter if an error happens
})
)
}),
switchMap(
Expand Down

0 comments on commit 69c9d3f

Please sign in to comment.