Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Chore: add test for navigation on document load error

shamoon22064ed0043b
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
index d9c4e64db..ed0d2a125 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
+++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
@@ -452,6 +452,18 @@ describe('DocumentDetailComponent', () => {
expect(navigateSpy).toHaveBeenCalledWith(['404'], { replaceUrl: true })
})
+ it('should navigate to 404 if error on load', () => {
+ jest
+ .spyOn(activatedRoute, 'paramMap', 'get')
+ .mockReturnValue(of(convertToParamMap({ id: 3, section: 'details' })))
+ const navigateSpy = jest.spyOn(router, 'navigate')
+ jest
+ .spyOn(documentService, 'get')
+ .mockReturnValue(throwError(() => new Error('not found')))
+ fixture.detectChanges()
+ expect(navigateSpy).toHaveBeenCalledWith(['404'], { replaceUrl: true })
+ })
+
it('should support save, close and show success toast', () => {
initNormally()
component.title = 'Foo Bar'