Add PageTitle class to canonicalize page names

This commit is contained in:
Yusuke Matsubara 2017-06-15 22:23:32 +09:00
parent 691acbf983
commit d241d36d66
12 changed files with 234 additions and 50 deletions

View file

@ -0,0 +1,23 @@
package fr.free.nrw.commons;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.hamcrest.CoreMatchers.is;
// TODO: use Robolectric and make it runnable without a connected device
@RunWith(AndroidJUnit4.class)
public class MediaTest {
@Test public void displayTitleShouldStripExtension() {
Media m = new Media("File:Example.jpg");
Assert.assertThat(m.getDisplayTitle(), is("Example"));
}
@Test public void displayTitleShouldUseSpaceForUnderscore() {
Media m = new Media("File:Example 1_2.jpg");
Assert.assertThat(m.getDisplayTitle(), is("Example 1 2"));
}
}