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

CamelCase method incorrectly handles PascalCase and camelCase #28

Open
JuicyLung91 opened this issue May 17, 2024 · 0 comments
Open

CamelCase method incorrectly handles PascalCase and camelCase #28

JuicyLung91 opened this issue May 17, 2024 · 0 comments

Comments

@JuicyLung91
Copy link

Describe the bug
The CamelCase method in the package is currently not handling PascalCase and camelCase strings correctly. Specifically, the method converts both lower case of the input when the input is written in PascalCase or CamelCase.

To Reproduce

  • Use the CamelCase method with the input TestEntity.
  • Use the CamelCase method with the input testEntity.
  • Observe that both inputs are converted to testentity.

Expected behavior
TestEntity should be converted to testEntity.
testEntity should remain testEntity.

Additional context
you can run this test

func TestCamelCaseHelper(t *testing.T) {
	tests := []struct {
		input    string
		expected string
	} {
		{"test", "test"},
		{"test entity", "testEntity"},
		{"test-entity", "testEntity"},
		{"test-entity_test", "testEntityTest"},
		{"test_entity", "testEntity"},
		{"TestEntity", "testEntity"},
		{"testEntity", "testEntity"},
		{"test_entity_definition", "testEntityDefinition"},
	}

	for _, test := range tests {
		actual := stringy.New(test.input).CamelCase().Get()
		if actual != test.expected {
			t.Errorf("Expected %s, got %s, input: %s", test.expected, actual, test.input)
		}
	}
}
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

No branches or pull requests

1 participant