Add startCase function
shekhargulati opened this issue · comments
Hi @shekhargulati, I would like to implement this new function if that's ok.
To start, I'm writing down some test cases to practice my rusty-ish TDD.
So far I have:
@Test(expected = IllegalArgumentException.class)
public void startCase_shouldThrowException() throws Exception {
startCase(null);
}
@Test
public void startCase_shouldStartCaseInputString() throws Exception {
assertThat(startCase(""), equalTo(""));
assertThat(startCase("ALL CAPS"), equalTo("All Caps"));
assertThat(startCase("camelCase"), equalTo("Camel Case"));
assertThat(startCase("kebab-case"), equalTo("'Kebab Case' Case"));
assertThat(startCase("Snake_case"), equalTo("Snake Case"));
assertThat(startCase(" spaces "), equalTo("Spaces"));
assertThat(startCase("spaces between words"), equalTo("Spaces Between Words"));
assertThat(startCase("--dashes--"), equalTo("Dashes"));
assertThat(startCase("dashes----between----words"), equalTo("Dashes Between Words"));
}
Is there some other use case/edge case I'm not considering that I should be aware of?
Thank you
The test cases are fine, but I think there needs to be a decision if the method should modify the input in cases of whitespaces/dashes/underscores etc. It might be a bit confusing if you pass a String like snake_case
and suddenly the _
character has been replaced by a whitespace. On the other hand a method to only capitalize the first character is already implemented.
Maybe the issue description should be extended by @shekhargulati to clarify the use case for this method.
@arcticicestudio Thank you for your comment. I agree with your thoughts/concerns.
Before implementing the startCase
function in this repo, I researched the web but couldn't find any real "source of truth" on how this function should behave.
The only implementation I could find was lodalodash's (https://lodash.com/docs/4.17.4#startCase), which indeed strips the string from -
and _
, and that's why I went with the same behavior.
@shekhargulati Please let us know. Thank you all