Skip to content

Commit

Permalink
fix(src): rename the executeCsv function into generateCsv
Browse files Browse the repository at this point in the history
  • Loading branch information
manushak committed Jul 16, 2024
1 parent e609d0c commit 669a422
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/__tests__/if-csv/util/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs/promises';
import {stringify} from 'csv-stringify/sync';
import {ERRORS} from '@grnsft/if-core/utils';

import {executeCsv, getManifestData} from '../../../if-csv/util/helpers';
import {generateCsv, getManifestData} from '../../../if-csv/util/helpers';
import {CsvOptions} from '../../../if-csv/types/csv';

const {ManifestValidationError} = ERRORS;
Expand All @@ -26,7 +26,7 @@ jest.mock('fs/promises', () => {
});

describe('if-csv/util/helpers: ', () => {
describe('executeCsv(): ', () => {
describe('generateCsv(): ', () => {
it('generates CSV file with correct data.', async () => {
const outputPath = 'output';
const columns = ['Path', 'Aggregated', '2023-12-12T00:00:00.000Z'];
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('if-csv/util/helpers: ', () => {
params: 'carbon',
};

await executeCsv(options);
await generateCsv(options);

expect(fs.writeFile).toHaveBeenCalledWith(
'output.csv',
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('if-csv/util/helpers: ', () => {
params: 'carbon',
};

await executeCsv(options);
await generateCsv(options);

expect.assertions(1);

Expand Down Expand Up @@ -162,7 +162,7 @@ describe('if-csv/util/helpers: ', () => {
params: 'carbon',
};

await executeCsv(options);
await generateCsv(options);

expect.assertions(1);
expect(fs.writeFile).toHaveBeenCalledWith(
Expand Down Expand Up @@ -190,7 +190,7 @@ describe('if-csv/util/helpers: ', () => {
params: 'carbon',
};

const result = await executeCsv(options);
const result = await generateCsv(options);

expect.assertions(1);
expect(result).toEqual(stringify(matrix, {columns}));
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('if-csv/util/helpers: ', () => {
params: 'carbon',
};

await executeCsv(options);
await generateCsv(options);

expect.assertions(1);
expect(fs.writeFile).toHaveBeenCalledWith(
Expand Down
4 changes: 2 additions & 2 deletions src/if-csv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {debugLogger} from '../common/util/debug-logger';
import {Manifest} from '../common/types/manifest';
import {logger} from '../common/util/logger';

import {executeCsv, getManifestData} from './util/helpers';
import {generateCsv, getManifestData} from './util/helpers';
import {parseIfCsvArgs} from './util/args';
import {CsvOptions} from './types/csv';

Expand All @@ -30,7 +30,7 @@ const IfCsv = async () => {
outputPath: output,
params,
};
const result = await executeCsv(options);
const result = await generateCsv(options);

if (!output && result) {
console.log(result);
Expand Down
4 changes: 2 additions & 2 deletions src/if-csv/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const getManifestData = async (manifest: string) => {
};

/**
* Executes a CSV generation based on the provided tree structure, context, output path, and params.
* Generates a CSV file based on the provided tree structure, context, output path, and params.
*/
export const executeCsv = async (options: CsvOptions) => {
export const generateCsv = async (options: CsvOptions) => {
const {tree, context, outputPath, params} = options;
const columns = ['Path'];
const matrix = [columns];
Expand Down

0 comments on commit 669a422

Please sign in to comment.