diff --git a/scripts/tools/combine-tools.js b/scripts/tools/combine-tools.js index 2fd0ef70d1c..6cd1d51ef9c 100644 --- a/scripts/tools/combine-tools.js +++ b/scripts/tools/combine-tools.js @@ -6,7 +6,6 @@ const schema = require("./tools-schema.json"); const Ajv = require("ajv") const addFormats = require("ajv-formats") const Fuse = require("fuse.js"); -const { error } = require("console"); const ajv = new Ajv() addFormats(ajv, ["uri"]) const validate = ajv.compile(schema) @@ -142,8 +141,6 @@ const combineTools = async (automatedTools, manualTools, toolsPath, tagsPath) => } catch (err) { throw new Error(`Error combining tools: ${err}`); } - fs.writeFileSync(toolsPath,JSON.stringify(finalTools)); - fs.writeFileSync(tagsPath,JSON.stringify({ languages: languageList, technologies: technologyList }),) } module.exports = { combineTools } \ No newline at end of file diff --git a/tests/fixtures/combineToolsData.js b/tests/fixtures/combineToolsData.js index c4a0021cc42..30ef6102979 100644 --- a/tests/fixtures/combineToolsData.js +++ b/tests/fixtures/combineToolsData.js @@ -192,12 +192,6 @@ const automatedToolsT12 = { } }; -const invalidManualToolsT13 = { - category1: { - toolsList: [{ title: 'Invalid Tool' }] - } -}; - module.exports = { expectedDataT1, manualToolsWithMissingData, @@ -211,7 +205,6 @@ module.exports = { manualToolsT8, automatedToolsT9, manualToolsT9, - invalidManualToolsT13, circularTool, automatedToolsT12, invalidAutomatedToolsT10, diff --git a/tests/tools/combine-tools.test.js b/tests/tools/combine-tools.test.js index d2c1345a670..78fee5441b2 100644 --- a/tests/tools/combine-tools.test.js +++ b/tests/tools/combine-tools.test.js @@ -14,12 +14,11 @@ const { manualToolsT8, automatedToolsT9, manualToolsT9, - invalidManualToolsT13, automatedToolsT12, invalidAutomatedToolsT10, manualToolsWithInvalidURLT11, circularTool -} = require('../fixtures/combineToolsData') +} = require('../fixtures/combineToolsData'); jest.mock('ajv', () => { return jest.fn().mockImplementation(() => ({ @@ -209,51 +208,53 @@ describe('combineTools function', () => { }); it('should throw an error when fs.writeFileSync fails', async () => { + let error; let invalidPath = "this/is/not/valid" try { await combineTools(automatedTools, manualTools, invalidPath, invalidPath); } catch (err) { + error = err; expect(err.message).toMatch(/ENOENT|EACCES/); } + expect(error).toBeDefined(); }); it('should throw an error when there is an invalid category', async () => { + let error; try { await combineTools(invalidAutomatedToolsT10, manualTools, toolsPath, tagsPath); } catch (err) { + error = err; expect(err.message).toContain('Error combining tools'); } + expect(error).toBeDefined(); }); it('should throw an error when URL parsing fails', async () => { + let error; try { await combineTools(automatedTools, manualToolsWithInvalidURLT11, toolsPath, tagsPath); } catch (err) { + error = err; expect(err.message).toContain('Invalid URL'); } + expect(error).toBeDefined(); }); it('should handle errors when processing tools with circular references', async () => { - + let error; circularTool.circular = circularTool; try { await combineTools(automatedToolsT12, {}, toolsPath, tagsPath); } catch (err) { + error = err; expect(err.message).toContain('Converting circular structure to JSON'); } - }); - - it('should throw an error when invalid manualTools data is passed', async () => { - - try { - await combineTools(automatedTools, invalidManualToolsT13, toolsPath, tagsPath); - } catch (err) { - expect(err.message).toBe('Error processing tool: Cannot read property \'language\' of undefined'); - } + expect(error).toBeDefined(); }); });