diff --git a/oereb_client/static/src/component/responsible_office/responsible_office.jsx b/oereb_client/static/src/component/responsible_office/responsible_office.jsx
index f0fdcdb2..5579631b 100644
--- a/oereb_client/static/src/component/responsible_office/responsible_office.jsx
+++ b/oereb_client/static/src/component/responsible_office/responsible_office.jsx
@@ -26,13 +26,22 @@ const OerebResponsibleOffice = function (props) {
const officeElements = offices.map((office, key) => {
const localizedName = getLocalizedText(office['Name'], currentLanguage, defaultLanguage);
const localizedUrl = getLocalizedText(office['OfficeAtWeb'], currentLanguage, defaultLanguage);
- return (
-
-
+ if (localizedUrl === null) {
+ return (
+
{localizedName}
-
-
- );
+
+ );
+ }
+ else {
+ return (
+
+
+ {localizedName}
+
+
+ );
+ }
});
return (
diff --git a/oereb_client/static/src/util/language.js b/oereb_client/static/src/util/language.js
index 18861f30..4e594364 100644
--- a/oereb_client/static/src/util/language.js
+++ b/oereb_client/static/src/util/language.js
@@ -1,5 +1,7 @@
+import {isArray} from "lodash";
+
export const getLocalizedText = function (multilingualText, language, defaultLanguage) {
- if (multilingualText.length > 0) {
+ if (isArray(multilingualText) && multilingualText.length > 0) {
let defaultValue = null;
for (let i = 0; i < multilingualText.length; i++) {
if (multilingualText[i]['Language'] === language) {
@@ -18,7 +20,7 @@ export const getLocalizedText = function (multilingualText, language, defaultLan
};
export const getLocalizedUrl = function (multilingualUrl, language, defaultLanguage) {
- if (multilingualUrl.length > 0) {
+ if (isArray(multilingualUrl) && multilingualUrl.length > 0) {
let defaultValue = null;
for (let i = 0; i < multilingualUrl.length; i++) {
if (multilingualUrl[i]['Language'] === language) {
diff --git a/test/js/component/responsible_office/__snapshots__/responsible_office.test.jsx.snap b/test/js/component/responsible_office/__snapshots__/responsible_office.test.jsx.snap
index c5df34f4..c01fc49b 100644
--- a/test/js/component/responsible_office/__snapshots__/responsible_office.test.jsx.snap
+++ b/test/js/component/responsible_office/__snapshots__/responsible_office.test.jsx.snap
@@ -22,3 +22,20 @@ exports[`responsible office component > should render responsible office 1`] = `
`;
+
+exports[`responsible office component > should render responsible office without url 1`] = `
+
+
+ -
+ extract.topic.responsible_office
+
+ -
+ Bundesamt für Verkehr BAV
+
+
+
+`;
diff --git a/test/js/component/responsible_office/responsible_office.test.jsx b/test/js/component/responsible_office/responsible_office.test.jsx
index fea930b1..7227359e 100644
--- a/test/js/component/responsible_office/responsible_office.test.jsx
+++ b/test/js/component/responsible_office/responsible_office.test.jsx
@@ -11,8 +11,6 @@ import extract from "../../../../samples/extract.json";
describe('responsible office component', () => {
- let component;
-
beforeEach(() => {
act(() => {
MainStore.dispatch(initLanguages({
@@ -20,18 +18,34 @@ describe('responsible office component', () => {
available: ['de']
}));
});
+ });
+
+ it('should render responsible office', () => {
const restrictions = groupRestrictionsByTopic(
extract.GetExtractByIdResponse.extract.RealEstate.RestrictionOnLandownership,
extract.GetExtractByIdResponse.extract.ConcernedTheme
)['chStatischeWaldgrenzen']['inForce'];
- component = render(
+ const component = render(
);
+ expect(component.asFragment()).toMatchSnapshot();
});
- it('should render responsible office', () => {
+ it('should render responsible office without url', () => {
+ const restrictions = groupRestrictionsByTopic(
+ extract.GetExtractByIdResponse.extract.RealEstate.RestrictionOnLandownership,
+ extract.GetExtractByIdResponse.extract.ConcernedTheme
+ )['chStatischeWaldgrenzen']['inForce'];
+ restrictions.forEach((restriction) => {
+ restriction['ResponsibleOffice']['OfficeAtWeb'] = null;
+ });
+ const component = render(
+
+
+
+ );
expect(component.asFragment()).toMatchSnapshot();
});
diff --git a/test/js/util/language.test.js b/test/js/util/language.test.js
index 124dd5d6..03e1e3a3 100644
--- a/test/js/util/language.test.js
+++ b/test/js/util/language.test.js
@@ -12,7 +12,15 @@ describe('getLocalizedText', () => {
}
];
- it('should return null', () => {
+ it('should return null for undefined input value', () => {
+ expect(getLocalizedText(undefined, 'en', 'en')).toBe(null);
+ });
+
+ it('should return null for null as input value', () => {
+ expect(getLocalizedText(null, 'en', 'en')).toBe(null);
+ });
+
+ it('should return null for empty list', () => {
expect(getLocalizedText([], 'en', 'en')).toBe(null);
});
@@ -41,7 +49,15 @@ describe('getLocalizedUrl', () => {
}
];
- it('should return null', () => {
+ it('should return null for undefined input value', () => {
+ expect(getLocalizedUrl(undefined, 'en', 'en')).toBe(null);
+ });
+
+ it('should return null for null as input value', () => {
+ expect(getLocalizedUrl(null, 'en', 'en')).toBe(null);
+ });
+
+ it('should return null for emtpy list', () => {
expect(getLocalizedUrl([], 'en', 'en')).toBe(null);
});