From f1b9a35ca7bb1605ad4e578698b736bb4c7ef36c Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Tue, 20 Oct 2020 17:36:48 +0200
Subject: [PATCH] chore: fix unit tests (pureConstant service now is
 responsible for fetching templates etc. catch error when it occurs)

---
 src/util/pureConstant.service.ts | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/util/pureConstant.service.ts b/src/util/pureConstant.service.ts
index 3c51b9e2d..2f9e6bafd 100644
--- a/src/util/pureConstant.service.ts
+++ b/src/util/pureConstant.service.ts
@@ -76,7 +76,11 @@ export class PureContantService implements OnDestroy{
   )
 
   public getTemplateEndpoint$ = this.http.get<any[]>(`${this.backendUrl}templates`, { responseType: 'json' }).pipe(
-    shareReplay(1)
+    catchError(() => {
+      this.log.warn(`fetching root /tempaltes error`)
+      return of([])
+    }),
+    shareReplay(),
   )
 
   public initFetchTemplate$ = this.getTemplateEndpoint$.pipe(
-- 
GitLab