Skip to content

Commit

Permalink
Add unit test for mime type parsing (JabRef#7452)
Browse files Browse the repository at this point in the history
Tests that mime type with parameter value is parsed correctly to exclude the parameter.
  • Loading branch information
binsu-kth authored and grundb committed Mar 4, 2021
1 parent 647c1b1 commit a55b2bc
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.jabref.gui.DialogService;
import org.jabref.gui.Globals;
import org.jabref.gui.externalfiletype.ExternalFileType;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.externalfiletype.StandardExternalFileType;
import org.jabref.gui.util.BackgroundTask;
Expand Down Expand Up @@ -262,4 +263,15 @@ void isSamePath() {
LinkedFileViewModel viewModel = new LinkedFileViewModel(linkedFile, entry, databaseContext, taskExecutor, dialogService, xmpPreferences, filePreferences, externalFileType);
assertTrue(viewModel.isGeneratedPathSameAsOriginal());
}


// Tests if added parameters to mimeType gets parsed to correct format.
@Test
void mimeTypeStringWithParameterIsReturnedAsWithoutParameter() {
Globals.prefs = JabRefPreferences.getInstance(); // required for task execution
ExternalFileTypes externalFileTypes = ExternalFileTypes.getInstance();
Optional<ExternalFileType> test = externalFileTypes.getExternalFileTypeByMimeType("text/html; charset=UTF-8");
String actual = test.get().toString();
assertEquals("URL",actual);
}
}

0 comments on commit a55b2bc

Please sign in to comment.