Skip to content

Commit

Permalink
Fix: find the test error + add other test (JabRef#3197)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachiri-ilias committed Feb 29, 2024
1 parent a8eafd7 commit 7fd5d07
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions src/test/java/org/jabref/gui/push/PushToTeXworksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@
import org.jabref.preferences.JabRefPreferences;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Disabled;
import org.mockito.Answers;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;


import javafx.beans.property.MapProperty;
import java.util.Arrays;


// @Disabled("Needs running TeXworks in the background. Start TeXworks with &")
class PushToTeXworksTest {
private PushToTeXworks pushToTeXworks;

Expand Down Expand Up @@ -55,6 +63,13 @@ public void setup() {

// Create a new instance of PushToTeXworks
pushToTeXworks = new PushToTeXworks(dialogService, preferencesService);


// Verify that the command path is correctly set in the preferences
MapProperty<String, String> actualCommandPaths = pushToApplicationPreferences.getCommandPaths();
Map<String, String> actualMap = actualCommandPaths.get();
String actualPath = actualMap.get(displayName);
assertEquals(teXworksClientPath, actualPath);
}

/**
Expand All @@ -77,18 +92,30 @@ void testDisplayName() {
*
* Method: getCommandLine()
*
* [TO FIX]: Test not working the commande path is not being set in the preferences
* Fix it in the setup() method
* [TO FIX]: Find a way set a command in the test
*
*/
// @Test
// void testGetCommandLine() {
// String keyString = "TestKey";
// String[] expectedCommand = new String[] {"/usr/bin/texworks", "--insert-text", "TestKey"};
// String[] actualCommand = pushToTeXworks.getCommandLine(keyString);
@Ignore("Needs to be fixed. Find a way to set a command in the test.")
@Test
void testGetCommandLine() {
String keyString = "TestKey";
String[] expectedCommand = new String[] {"/usr/bin/texworks", "--insert-text", "TestKey"};

// assertEquals(expectedCommand, actualCommand);
// }
}
String[] actualCommand = pushToTeXworks.getCommandLine(keyString);
}

/**
* This test run the external application to push the keys to be cited
*
* Method: pushEntries()
*
* [Precondition]: TeXworks should be running in the background
*/
@Disabled("Disabled as it needs running TeXworks in the background. Start TeXworks with &")
@Test
void pushEntries() {
pushToTeXworks.pushEntries(null, null, "key1,key2");
}
}


0 comments on commit 7fd5d07

Please sign in to comment.