Skip to content

Commit 88dd4ff

Browse files
fergiektidian-ferguson-uhsmelloware
authoredNov 5, 2023
fix(core): inconsistent kebab casing comparison (#937)
* fix(core): inconsistent kebab casing comparison Fixing an issue where operationNames were being filtered out and not provided to builder.footer. generateTargetTags returns kebab-cased tags which are then compared to operation tags which have not been run through the kebab routine. map all operation tags with kebab prior to checking that the tags include a tag. * fix(core): inconsistent kebab casing comparison Fixing an issue where operationNames were being filtered out and not provided to builder.footer. generateTargetTags returns kebab-cased tags which are then compared to operation tags which have not been run through the kebab routine. map all operation tags with kebab prior to checking that the tags include a tag. Added some additional unit tests to ensure that the kebab routine is Idempotent. * Update case.test.ts --------- Co-authored-by: Ian Ferguson <ian.ferguson@uhs.nhs.uk> Co-authored-by: Melloware <mellowaredev@gmail.com>
1 parent 13d3249 commit 88dd4ff

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
 

‎packages/core/src/utils/case.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it } from 'vitest';
22
import { pascal } from './case';
3+
import { kebab } from './case';
34

45
describe('pascal case testing', () => {
56
it('should convert to pascal case', () => {
@@ -26,3 +27,22 @@ describe('pascal case testing', () => {
2627
expect(pascal('foo_bar_API')).toBe('FooBarAPI');
2728
});
2829
});
30+
31+
describe('kebab-case a few examples', () => {
32+
//fix #937, issue #936, results in kebab routine being potentially called
33+
//on a string **repeatedly**.
34+
//Do some basic kebab case checks
35+
//Additionally, test that the kebab routine is Idempotent
36+
[
37+
['Pet', 'pet'],
38+
['pet', 'pet'],
39+
['PetTag', 'pet-tag'],
40+
['pet-tag', 'pet-tag'],
41+
['PetTagWithFourWords', 'pet-tag-with-four-words'],
42+
['pet-tag-with-four-words', 'pet-tag-with-four-words'],
43+
].forEach(([input, expected]) => {
44+
it(`should process ${input} to ${expected}`, () => {
45+
expect(kebab(input)).toBe(expected);
46+
});
47+
});
48+
});

‎packages/core/src/writers/target-tags.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const generateTargetForTags = (
104104
isAngularClient ? mutator.hasThirdArg : mutator.hasSecondArg,
105105
);
106106
const operationNames = Object.values(builder.operations)
107-
.filter(({ tags }) => tags.includes(tag))
107+
.filter(({ tags }) => tags.map(kebab).includes(kebab(tag)))
108108
.map(({ operationName }) => operationName);
109109

110110
const typescriptVersion =

0 commit comments

Comments
 (0)
Please sign in to comment.