Skip to content

Commit

Permalink
fegwg
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Oct 19, 2024
1 parent cf6a37d commit 0a83f54
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions tests/build-tools.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { resolve } = require('path');
const { buildTools } = require('../scripts/build-tools');
const { tagsData, manualTools, mockConvertedData, mockExtractData } = require('../tests/fixtures/buildToolsData');
const fs = require('fs');
const { beforeEach, afterEach } = require('node:test');

jest.mock('axios');
jest.mock('../scripts/tools/categorylist', () => ({
Expand All @@ -29,15 +30,17 @@ describe('buildTools', () => {
const tagsPath = resolve(testDir, 'all-tags.json');
const automatedToolsPath = resolve(testDir, 'tools-automated.json');
const manualToolsPath = resolve(testDir, 'tools-manual.json');

if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}
if (!fs.existsSync(manualToolsPath)) {
fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools));
}

let consoleErrorMock;

beforeAll(() => {
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(() => {});
});

Expand All @@ -50,6 +53,10 @@ describe('buildTools', () => {

beforeEach(() => {
jest.clearAllMocks();

if (!fs.existsSync(manualToolsPath)) {
fs.writeFileSync(manualToolsPath, JSON.stringify(manualTools));
}
});

it('should extract, convert, combine tools, and write to file', async () => {
Expand Down

0 comments on commit 0a83f54

Please sign in to comment.