Skip to content

Commit

Permalink
refactor: removing redundant addPreference method in Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
giulong committed Jan 5, 2025
1 parent c93fce2 commit 78aacf9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ void buildCapabilities() {

firefox
.getPreferences()
.forEach(this::addPreference);
}

void addPreference(final String key, final Object value) {
capabilities.addPreference(key, value instanceof Boolean || value instanceof Integer ? value : String.valueOf(value));
.forEach(capabilities::addPreference);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockedConstruction;
Expand All @@ -19,10 +16,8 @@
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import static org.mockito.Mockito.*;

class FirefoxTest {
Expand Down Expand Up @@ -136,34 +131,4 @@ void buildCapabilitiesFromNoBinary() {

firefoxOptionsMockedConstruction.close();
}

@DisplayName("addPreference should add the correct preference based on the value type")
@ParameterizedTest(name = "with value {0} we expect {1}")
@MethodSource("valuesProvider")
void addPreference(final Object value, final Object expected) {
firefox.capabilities = firefoxOptions;

firefox.addPreference("key", value);
verify(firefoxOptions).addPreference("key", expected);
}

static Stream<Arguments> valuesProvider() {
final DummyObject dummyObject = new DummyObject();

return Stream.of(
arguments(true, true),
arguments(123, 123),
arguments("123", "123"),
arguments("true", "true"),
arguments(dummyObject, dummyObject.toString())
);
}

private static final class DummyObject {

@Override
public String toString() {
return "toString";
}
}
}

0 comments on commit 78aacf9

Please sign in to comment.