Skip to content

Commit 9f9cf09

Browse files
committed
test: cover array-valued plugin options in dedup
1 parent 41215a2 commit 9f9cf09

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

packages/openapi-ts/src/__tests__/index.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,50 @@ describe('createClient', () => {
414414
warnSpy.mockRestore();
415415
});
416416

417+
it('does not warn when array-valued options differ only in element key order', async () => {
418+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
419+
420+
await createClient({
421+
...baseConfig,
422+
plugins: [
423+
{
424+
items: [{ from: 'foo', name: 'bar' }],
425+
name: '@hey-api/typescript',
426+
} as never,
427+
{
428+
items: [{ name: 'bar', from: 'foo' }],
429+
name: '@hey-api/typescript',
430+
} as never,
431+
],
432+
});
433+
434+
expect(conflictWarnings(warnSpy)).toHaveLength(0);
435+
436+
warnSpy.mockRestore();
437+
});
438+
439+
it('warns when array-valued options differ in element order', async () => {
440+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
441+
442+
await createClient({
443+
...baseConfig,
444+
plugins: [
445+
{
446+
items: [{ from: 'a', name: 'x' }, { from: 'b', name: 'y' }],
447+
name: '@hey-api/typescript',
448+
} as never,
449+
{
450+
items: [{ from: 'b', name: 'y' }, { from: 'a', name: 'x' }],
451+
name: '@hey-api/typescript',
452+
} as never,
453+
],
454+
});
455+
456+
expect(conflictWarnings(warnSpy)).toHaveLength(1);
457+
458+
warnSpy.mockRestore();
459+
});
460+
417461
it('does not warn when function-valued options have identical source', async () => {
418462
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
419463
const transform = (s: string) => s.toUpperCase();

0 commit comments

Comments
 (0)