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

Add startCase function #62

Open
shekhargulati opened this issue Jul 19, 2016 · 3 comments
Open

Add startCase function #62

shekhargulati opened this issue Jul 19, 2016 · 3 comments

Comments

@shekhargulati
Copy link
Owner

No description provided.

@engfragui
Copy link
Contributor

engfragui commented Oct 15, 2017

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

@arcticicestudio
Copy link

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.

@engfragui
Copy link
Contributor

engfragui commented Oct 19, 2017

@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

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

3 participants