Skip to content

Commit

Permalink
chore: update test file
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Aug 16, 2024
1 parent 3b19d44 commit c5bd497
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import type { PartialConfig } from './getConfig';
import { getConfig } from './getConfig';

export default (configs?: PartialConfig) =>
getConfig(configs).map((config) => {
getConfig(configs).forEach((config) => {
const tree = getDirentTree(config.input);

const createFilePaths = (tree: DirentTree): string[] => {
25 changes: 13 additions & 12 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs';
import fs, { copyFileSync } from 'fs';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import build from '../src';
import type { ConfigFile } from '../src/getConfig';
@@ -7,20 +7,21 @@ describe('cli test', () => {
beforeAll(() => fs.mkdirSync('_samples'));
afterAll(() => fs.promises.rmdir('_samples', { recursive: true }));

test('main', () => {
const configs: ConfigFile[] = require('../aspida.config.js');
const configs: ConfigFile[] = require('../aspida.config.js');

return Promise.all(
configs.map(async (config) => {
const originalFile = config.openapi?.outputFile ?? `${config.input}.json`;
const outputFile = `_${originalFile}`;
test.each(configs)('$input', (config) => {
const originalFile = config.openapi?.outputFile ?? `${config.input}.json`;
const outputFile = `_${originalFile}`;

await build({ ...config, openapi: { outputFile } })[0];
if (config.input.endsWith('openapi')) {
// override doc info
copyFileSync(`${config.input}.json`, outputFile);
}

expect(fs.readFileSync(outputFile, 'utf8')).toBe(
fs.readFileSync(originalFile, 'utf8').replace(/\r/g, ''),
);
}),
build({ ...config, openapi: { outputFile } });

expect(fs.readFileSync(outputFile, 'utf8')).toBe(
fs.readFileSync(originalFile, 'utf8').replace(/\r/g, ''),
);
});
});

0 comments on commit c5bd497

Please sign in to comment.