package com.atlassian.stash.internal.web.soy.functions;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

@RunWith(MockitoJUnitRunner.class)
public class CamelCaseToHyphenatedFunctionTest {

    @Test
    public void testCamelCaseToHyphenated() {

        assertThat(new CamelCaseToHyphenatedFunction().apply("foobar"), equalTo("foobar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("fooBar"), equalTo("foo-bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("FooBar"), equalTo("foo-bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("FooBarBar"), equalTo("foo-bar-bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("foobar-Bar"), equalTo("foobar-bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("foobar-bar"), equalTo("foobar-bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("FooBar-Bar"), equalTo("foo-bar-bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("---"), equalTo("---"));
        assertThat(new CamelCaseToHyphenatedFunction().apply(""), equalTo(""));
        assertThat(new CamelCaseToHyphenatedFunction().apply("-foo"), equalTo("-foo"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("-Foo"), equalTo("-foo"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("-FOO"), equalTo("-f-o-o"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("FOO"), equalTo("f-o-o"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("$FOO"), equalTo("$-f-o-o"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("$fOO"), equalTo("$f-o-o"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("$foo"), equalTo("$foo"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("foo$bar"), equalTo("foo$bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("foo$Bar"), equalTo("foo$-bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("foo_bar"), equalTo("foo_bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("foo_Bar"), equalTo("foo_bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("foo bar"), equalTo("foo-bar"));
        assertThat(new CamelCaseToHyphenatedFunction().apply("foo Bar"), equalTo("foo-bar"));
    }
}
