Skip to content

Commit

Permalink
build-tools test update
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Oct 18, 2024
1 parent a1af4f7 commit 9d38d41
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/build-tools.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ describe('buildTools', () => {
let consoleErrorMock;

beforeAll(() => {
fs.mkdirSync(testDir, { recursive: true });
fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools));
if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}
if (!fs.existsSync(manualToolsPath)) {
fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools));
}
consoleErrorMock = jest.spyOn(console, 'error').mockImplementation(() => {});
});

afterAll(() => {
fs.rmSync(testDir, { recursive: true, force: true });
if (fs.existsSync(testDir)) {
fs.rmSync(testDir, { recursive: true, force: true });
}
consoleErrorMock.mockRestore();
});

Expand All @@ -49,6 +55,10 @@ describe('buildTools', () => {
it('should extract, convert, combine tools, and write to file', async () => {
axios.get.mockResolvedValue({ data: mockExtractData });

if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}

await buildTools(automatedToolsPath, manualToolsPath, toolsPath, tagsPath);

const automatedToolsContent = JSON.parse(fs.readFileSync(automatedToolsPath, 'utf8'));
Expand All @@ -65,7 +75,6 @@ describe('buildTools', () => {
expect(combinedToolsContent["Category2"].description).toEqual(mockConvertedData["Category2"].description);

expect(tagsContent).toEqual(tagsData);

});

it('should handle getData error', async () => {
Expand Down

0 comments on commit 9d38d41

Please sign in to comment.