Skip to content

Commit e35dc0b

Browse files
committed
test: update tests
1 parent d20b54f commit e35dc0b

File tree

26 files changed

+272
-2272
lines changed

26 files changed

+272
-2272
lines changed

packages/openapi-ts-tests/main/test/2.0.x.test.ts

Lines changed: 0 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -409,183 +409,4 @@ describe(`OpenAPI ${version}`, () => {
409409
}),
410410
);
411411
});
412-
413-
describe('multi config', () => {
414-
it('generates outputs for all configs', async () => {
415-
const configA = createConfig({
416-
input: 'external.yaml',
417-
output: 'multi-external',
418-
});
419-
const configB = createConfig({
420-
input: 'enum-names-values.json',
421-
output: 'multi-enum-names-values',
422-
});
423-
424-
await createClient([configA, configB]);
425-
426-
const filesA = getFilePaths(configA.output);
427-
const filesB = getFilePaths(configB.output);
428-
429-
await Promise.all(
430-
filesA.map(async (filePath) => {
431-
const fileContent = fs.readFileSync(filePath, 'utf-8');
432-
await expect(fileContent).toMatchFileSnapshot(
433-
path.join(
434-
__dirname,
435-
'__snapshots__',
436-
version,
437-
filePath.slice(outputDir.length + 1),
438-
),
439-
);
440-
}),
441-
);
442-
443-
await Promise.all(
444-
filesB.map(async (filePath) => {
445-
const fileContent = fs.readFileSync(filePath, 'utf-8');
446-
await expect(fileContent).toMatchFileSnapshot(
447-
path.join(
448-
__dirname,
449-
'__snapshots__',
450-
version,
451-
filePath.slice(outputDir.length + 1),
452-
),
453-
);
454-
}),
455-
);
456-
});
457-
});
458-
459-
describe('multi input', () => {
460-
it('parses multiple inputs (object + string) without errors', async () => {
461-
const specsBase = path.join(getSpecsPath(), version);
462-
await expect(
463-
createClient({
464-
dryRun: true,
465-
input: [
466-
{ path: path.join(specsBase, 'multi-a.json') },
467-
path.join(specsBase, 'multi-b.json'),
468-
],
469-
logs: { level: 'silent' },
470-
output: path.join(outputDir, 'multi-input'),
471-
plugins: ['@hey-api/typescript'],
472-
}),
473-
).resolves.not.toThrow();
474-
});
475-
});
476-
477-
describe('multi output', () => {
478-
it('generates multiple string outputs without errors', async () => {
479-
const results = await createClient({
480-
input: path.join(getSpecsPath(), version, 'external.yaml'),
481-
logs: { level: 'silent' },
482-
output: [
483-
path.join(outputDir, 'multi-output-string-1'),
484-
path.join(outputDir, 'multi-output-string-2'),
485-
],
486-
plugins: ['@hey-api/typescript'],
487-
});
488-
489-
expect(results).toHaveLength(2);
490-
491-
// Verify both output directories were created
492-
expect(fs.existsSync(path.join(outputDir, 'multi-output-string-1'))).toBe(
493-
true,
494-
);
495-
expect(fs.existsSync(path.join(outputDir, 'multi-output-string-2'))).toBe(
496-
true,
497-
);
498-
});
499-
500-
it('generates multiple output objects with different configurations', async () => {
501-
const results = await createClient({
502-
input: path.join(getSpecsPath(), version, 'external.yaml'),
503-
logs: { level: 'silent' },
504-
output: [
505-
{
506-
clean: true,
507-
indexFile: true,
508-
path: path.join(outputDir, 'multi-output-config-1'),
509-
},
510-
{
511-
clean: false,
512-
indexFile: false,
513-
path: path.join(outputDir, 'multi-output-config-2'),
514-
},
515-
],
516-
plugins: ['@hey-api/typescript'],
517-
});
518-
519-
expect(results).toHaveLength(2);
520-
521-
// Verify both output directories were created
522-
expect(fs.existsSync(path.join(outputDir, 'multi-output-config-1'))).toBe(
523-
true,
524-
);
525-
expect(fs.existsSync(path.join(outputDir, 'multi-output-config-2'))).toBe(
526-
true,
527-
);
528-
529-
// Verify index files are created/not created based on configuration
530-
expect(
531-
fs.existsSync(
532-
path.join(outputDir, 'multi-output-config-1', 'index.ts'),
533-
),
534-
).toBe(true);
535-
expect(
536-
fs.existsSync(
537-
path.join(outputDir, 'multi-output-config-2', 'index.ts'),
538-
),
539-
).toBe(false);
540-
});
541-
542-
it('generates mixed string and object outputs', async () => {
543-
const results = await createClient({
544-
input: path.join(getSpecsPath(), version, 'external.yaml'),
545-
logs: { level: 'silent' },
546-
output: [
547-
path.join(outputDir, 'multi-output-mixed-string'),
548-
{
549-
indexFile: false,
550-
path: path.join(outputDir, 'multi-output-mixed-object'),
551-
},
552-
],
553-
plugins: ['@hey-api/typescript'],
554-
});
555-
556-
expect(results).toHaveLength(2);
557-
558-
// Verify both output directories were created
559-
expect(
560-
fs.existsSync(path.join(outputDir, 'multi-output-mixed-string')),
561-
).toBe(true);
562-
expect(
563-
fs.existsSync(path.join(outputDir, 'multi-output-mixed-object')),
564-
).toBe(true);
565-
});
566-
567-
it('preserves global configuration across multiple outputs', async () => {
568-
const results = await createClient({
569-
experimentalParser: true,
570-
input: path.join(getSpecsPath(), version, 'external.yaml'),
571-
logs: { level: 'silent' },
572-
output: [
573-
path.join(outputDir, 'multi-output-global-1'),
574-
path.join(outputDir, 'multi-output-global-2'),
575-
],
576-
plugins: ['@hey-api/typescript', '@hey-api/sdk'],
577-
});
578-
579-
expect(results).toHaveLength(2);
580-
581-
// Both results should have the same global configuration
582-
results.forEach((result) => {
583-
if ('config' in result) {
584-
expect(result.config.experimentalParser).toBe(true);
585-
expect(result.config.plugins['@hey-api/typescript']).toBeDefined();
586-
expect(result.config.plugins['@hey-api/sdk']).toBeDefined();
587-
}
588-
});
589-
});
590-
});
591412
});

packages/openapi-ts-tests/main/test/3.0.x.test.ts

Lines changed: 0 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -686,184 +686,4 @@ describe(`OpenAPI ${version}`, () => {
686686
}),
687687
);
688688
});
689-
690-
describe('multi config', () => {
691-
it('generates outputs for all configs', async () => {
692-
const configA = createConfig({
693-
input: 'external.yaml',
694-
output: 'multi-external',
695-
});
696-
const configB = createConfig({
697-
input: 'enum-inline.json',
698-
output: 'multi-enum-inline',
699-
parser: { transforms: { enums: 'root' } },
700-
});
701-
702-
await createClient([configA, configB]);
703-
704-
const filesA = getFilePaths(configA.output);
705-
const filesB = getFilePaths(configB.output);
706-
707-
await Promise.all(
708-
filesA.map(async (filePath) => {
709-
const fileContent = fs.readFileSync(filePath, 'utf-8');
710-
await expect(fileContent).toMatchFileSnapshot(
711-
path.join(
712-
__dirname,
713-
'__snapshots__',
714-
version,
715-
filePath.slice(outputDir.length + 1),
716-
),
717-
);
718-
}),
719-
);
720-
721-
await Promise.all(
722-
filesB.map(async (filePath) => {
723-
const fileContent = fs.readFileSync(filePath, 'utf-8');
724-
await expect(fileContent).toMatchFileSnapshot(
725-
path.join(
726-
__dirname,
727-
'__snapshots__',
728-
version,
729-
filePath.slice(outputDir.length + 1),
730-
),
731-
);
732-
}),
733-
);
734-
});
735-
});
736-
737-
describe('multi input', () => {
738-
it('parses multiple inputs (object + string) without errors', async () => {
739-
const specsBase = path.join(getSpecsPath(), version);
740-
await expect(
741-
createClient({
742-
dryRun: true,
743-
input: [
744-
{ path: path.join(specsBase, 'multi-a.yaml') },
745-
path.join(specsBase, 'multi-b.yaml'),
746-
],
747-
logs: { level: 'silent' },
748-
output: path.join(outputDir, 'multi-input'),
749-
plugins: ['@hey-api/typescript'],
750-
}),
751-
).resolves.not.toThrow();
752-
});
753-
});
754-
755-
describe('multi output', () => {
756-
it('generates multiple string outputs without errors', async () => {
757-
const results = await createClient({
758-
input: path.join(getSpecsPath(), version, 'external.yaml'),
759-
logs: { level: 'silent' },
760-
output: [
761-
path.join(outputDir, 'multi-output-string-1'),
762-
path.join(outputDir, 'multi-output-string-2'),
763-
],
764-
plugins: ['@hey-api/typescript'],
765-
});
766-
767-
expect(results).toHaveLength(2);
768-
769-
// Verify both output directories were created
770-
expect(fs.existsSync(path.join(outputDir, 'multi-output-string-1'))).toBe(
771-
true,
772-
);
773-
expect(fs.existsSync(path.join(outputDir, 'multi-output-string-2'))).toBe(
774-
true,
775-
);
776-
});
777-
778-
it('generates multiple output objects with different configurations', async () => {
779-
const results = await createClient({
780-
input: path.join(getSpecsPath(), version, 'external.yaml'),
781-
logs: { level: 'silent' },
782-
output: [
783-
{
784-
clean: true,
785-
indexFile: true,
786-
path: path.join(outputDir, 'multi-output-config-1'),
787-
},
788-
{
789-
clean: false,
790-
indexFile: false,
791-
path: path.join(outputDir, 'multi-output-config-2'),
792-
},
793-
],
794-
plugins: ['@hey-api/typescript'],
795-
});
796-
797-
expect(results).toHaveLength(2);
798-
799-
// Verify both output directories were created
800-
expect(fs.existsSync(path.join(outputDir, 'multi-output-config-1'))).toBe(
801-
true,
802-
);
803-
expect(fs.existsSync(path.join(outputDir, 'multi-output-config-2'))).toBe(
804-
true,
805-
);
806-
807-
// Verify index files are created/not created based on configuration
808-
expect(
809-
fs.existsSync(
810-
path.join(outputDir, 'multi-output-config-1', 'index.ts'),
811-
),
812-
).toBe(true);
813-
expect(
814-
fs.existsSync(
815-
path.join(outputDir, 'multi-output-config-2', 'index.ts'),
816-
),
817-
).toBe(false);
818-
});
819-
820-
it('generates mixed string and object outputs', async () => {
821-
const results = await createClient({
822-
input: path.join(getSpecsPath(), version, 'external.yaml'),
823-
logs: { level: 'silent' },
824-
output: [
825-
path.join(outputDir, 'multi-output-mixed-string'),
826-
{
827-
indexFile: false,
828-
path: path.join(outputDir, 'multi-output-mixed-object'),
829-
},
830-
],
831-
plugins: ['@hey-api/typescript'],
832-
});
833-
834-
expect(results).toHaveLength(2);
835-
836-
// Verify both output directories were created
837-
expect(
838-
fs.existsSync(path.join(outputDir, 'multi-output-mixed-string')),
839-
).toBe(true);
840-
expect(
841-
fs.existsSync(path.join(outputDir, 'multi-output-mixed-object')),
842-
).toBe(true);
843-
});
844-
845-
it('preserves global configuration across multiple outputs', async () => {
846-
const results = await createClient({
847-
experimentalParser: true,
848-
input: path.join(getSpecsPath(), version, 'external.yaml'),
849-
logs: { level: 'silent' },
850-
output: [
851-
path.join(outputDir, 'multi-output-global-1'),
852-
path.join(outputDir, 'multi-output-global-2'),
853-
],
854-
plugins: ['@hey-api/typescript', '@hey-api/sdk'],
855-
});
856-
857-
expect(results).toHaveLength(2);
858-
859-
// Both results should have the same global configuration
860-
results.forEach((result) => {
861-
if ('config' in result) {
862-
expect(result.config.experimentalParser).toBe(true);
863-
expect(result.config.plugins['@hey-api/typescript']).toBeDefined();
864-
expect(result.config.plugins['@hey-api/sdk']).toBeDefined();
865-
}
866-
});
867-
});
868-
});
869689
});

0 commit comments

Comments
 (0)