Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(titleCase): insert extra space when convert valid string #97

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ntnyq
Copy link

@ntnyq ntnyq commented Nov 20, 2024

This PR resolves #96 and adds test cases for other converters while convert valid string.

@ntnyq ntnyq changed the title fix(titleCase): remove unexpected space fix(titleCase): insert extra space when convert valid string Nov 20, 2024
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (32ee7f5) to head (a9cbd9a).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #97   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          340       409   +69     
  Branches        39        45    +6     
=========================================
+ Hits           340       409   +69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

src/index.ts Outdated Show resolved Hide resolved
@@ -140,6 +147,7 @@ describe("titleCase", () => {
["foo", "Foo"],
["foo-bar", "Foo Bar"],
["this-IS-aTitle", "This is a Title"],
["Foo Bar", "Foo Bar"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add at least to types test as well? (for types we can do simply similar fix with trim should be fine)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some changes to types and added types test cases for TrainCase and TitleCase(TrainCase with space joiner).

There are still two cases didn't pass. That's because titleCase and trainCase use filter(Boolean) to filter empty string. I don't know how to fix the type properly so I add a @ts-expect-error comment above it.

Could you do some help?

@@ -54,15 +54,15 @@ export function splitByCase<
if (previousSplitter === false) {
// Case rising edge
if (previousUpper === false && isUpper === true) {
parts.push(buff);
parts.push(buff.trim());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we could fix algorithm that does not add trailing space in first place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

titleCase insert extra space when convert a valid titleCase string
2 participants