From 22be6f79ed4c8446fd1298e5eb6b45bb9222d225 Mon Sep 17 00:00:00 2001 From: Mathieu Suen Date: Thu, 30 Sep 2021 17:54:40 +0200 Subject: SONAR-15466 Add link for SonarLint connected mode --- .../src/__tests__/BrokenLinkSafetyNet.test.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'server/sonar-docs/src/__tests__') diff --git a/server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js b/server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js index d1d31eb30c9..74c4598bd57 100644 --- a/server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js +++ b/server/sonar-docs/src/__tests__/BrokenLinkSafetyNet.test.js @@ -72,16 +72,19 @@ it('should have valid links in trees files', () => { it('should have valid links in suggestions file', () => { const file = 'EmbedDocsSuggestions.json'; const suggestions = JSON.parse(fs.readFileSync(path.join(rootPath, file), 'utf8')); - let hasErrors = false; - Object.keys(suggestions).forEach(key => { - suggestions[key].forEach(suggestion => { + const hasErrors = Object.keys(suggestions).some(key => { + return suggestions[key].some(suggestion => { if (!suggestion.link.startsWith('/documentation/')) { - console.log(`[${suggestion.link}] should starts with "/documentation/", in ${file}`); - hasErrors = true; - } else if (!urlExists(parsedFiles, suggestion.link.replace('/documentation', ''))) { + console.log( + `[${suggestion.link}] should starts with "/documentation/" or be a valid url, in ${file}` + ); + return true; + } + if (!urlExists(parsedFiles, suggestion.link.replace('/documentation', ''))) { console.log(`[${suggestion.link}] is not a valid link, in ${file}`); - hasErrors = true; + return true; } + return false; }); }); expect(hasErrors).toBe(false); -- cgit v1.2.3