Skip to content

Commit

Permalink
replaced getAttribute with getDomAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
grossopa committed Dec 15, 2024
1 parent e06706f commit dec0dc3
Show file tree
Hide file tree
Showing 89 changed files with 333 additions and 328 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,34 @@ void getComponentName() {
@Test
void validate() {
when(element.getTagName()).thenReturn("button");
when(element.getAttribute("class")).thenReturn("sss-btn sss-btn-primary");
when(element.getDomAttribute("class")).thenReturn("sss-btn sss-btn-primary");
assertTrue(testSubject.validate());
}

@Test
void validateNegative1() {
when(element.getTagName()).thenReturn("label");
when(element.getAttribute("class")).thenReturn("sss-btn sss-btn-primary");
when(element.getDomAttribute("class")).thenReturn("sss-btn sss-btn-primary");
assertFalse(testSubject.validate());
}

@Test
void validateNegative2() {
when(element.getTagName()).thenReturn("button");
when(element.getAttribute("class")).thenReturn("sss-ddd sss-btn-primary");
when(element.getDomAttribute("class")).thenReturn("sss-ddd sss-btn-primary");
assertFalse(testSubject.validate());
}

@Test
void isLoadingTrue() {
when(element.getTagName()).thenReturn("button");
when(element.getAttribute("class")).thenReturn("sss-btn sss-btn-loading");
when(element.getDomAttribute("class")).thenReturn("sss-btn sss-btn-loading");
assertTrue(testSubject.isLoading());
}

@Test
void isLoadingFalse() {
when(element.getAttribute("class")).thenReturn("sss-ddd sss-btn-primary");
when(element.getDomAttribute("class")).thenReturn("sss-ddd sss-btn-primary");
assertFalse(testSubject.isLoading());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* @author Jack Yin
* @since 1.0
*/
@SuppressWarnings("deprecation")
class HtmlSelectTest {

HtmlSelect testSubject;
Expand All @@ -53,8 +54,10 @@ class HtmlSelectTest {

private WebElement createOption(String value, String label, Integer index, boolean selected) {
WebElement element = mock(WebElement.class);
when(element.getDomAttribute("value")).thenReturn(value);
when(element.getAttribute("value")).thenReturn(value);
when(element.getText()).thenReturn(label);
when(element.getDomAttribute("index")).thenReturn(String.valueOf(index));
when(element.getAttribute("index")).thenReturn(String.valueOf(index));
when(element.isSelected()).thenReturn(selected);
when(element.isEnabled()).thenReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public String getIsDisabledCss() {
@Override
public boolean isDisabled(WebComponent component) {
return ComponentConfig.super.isDisabled(component) || "true".equalsIgnoreCase(
component.getAttribute("aria-disabled"));
component.getDomAttribute("aria-disabled"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public boolean validate() {

@Override
public boolean isEnabled() {
return element.getAttribute("disabled") == null;
return element.getDomAttribute("disabled") == null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public boolean validate() {
* @return the column count
*/
public int getCols() {
return Integer.parseInt(element.getAttribute("cols"));
return Integer.parseInt(element.getDomAttribute("cols"));
}

public List<MatGridTile> getGridTiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public boolean validate() {
* @return the row span
*/
public int getRowSpan() {
return Integer.parseInt(this.getAttribute("rowspan"));
return Integer.parseInt(this.getDomAttribute("rowspan"));
}

/**
Expand All @@ -78,6 +78,6 @@ public int getRowSpan() {
* @return the row span
*/
public int getColSpan() {
return Integer.parseInt(this.getAttribute("colspan"));
return Integer.parseInt(this.getDomAttribute("colspan"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public boolean validate() {
* @return the min value of the progress bar
*/
public String getMinValue() {
return this.getAttribute("aria-valuemin");
return this.getDomAttribute("aria-valuemin");
}

/**
Expand All @@ -81,7 +81,7 @@ public String getMinValue() {
* @return the max value of the progress bar
*/
public String getMaxValue() {
return this.getAttribute("aria-valuemax");
return this.getDomAttribute("aria-valuemax");
}

/**
Expand All @@ -90,7 +90,7 @@ public String getMaxValue() {
* @return the current of the progress bar
*/
public String getValue() {
return this.getAttribute("aria-valuenow");
return this.getDomAttribute("aria-valuenow");
}

/**
Expand All @@ -99,7 +99,7 @@ public String getValue() {
* @return the current mode
*/
public Mode getMode() {
return Mode.valueOf(upperCase(this.getAttribute("mode")));
return Mode.valueOf(upperCase(this.getDomAttribute("mode")));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public boolean validate() {
*/
@Override
public String getValue() {
return getAttribute("aria-valuenow");
return getDomAttribute("aria-valuenow");
}

/**
Expand Down Expand Up @@ -145,7 +145,7 @@ public Double getValueDouble() {
*/
@Override
public String getMinValue() {
return getAttribute("aria-valuemin");
return getDomAttribute("aria-valuemin");
}

/**
Expand Down Expand Up @@ -197,7 +197,7 @@ public Double getMinValueDouble() {
*/
@Override
public String getMaxValue() {
return getAttribute("aria-valuemax");
return getDomAttribute("aria-valuemax");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ public boolean validate() {

@Override
public boolean isSelected() {
return "true".equalsIgnoreCase(this.getAttribute("aria-selected"));
return "true".equalsIgnoreCase(this.getDomAttribute("aria-selected"));
}

@Override
public boolean isEnabled() {
return !"true".equalsIgnoreCase(this.getAttribute("aria-disabled"));
return !"true".equalsIgnoreCase(this.getDomAttribute("aria-disabled"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void isDisabled2() {
WebElement element = mock(WebElement.class);
when(component.getWrappedElement()).thenReturn(element);
when(element.isEnabled()).thenReturn(true);
when(component.getAttribute("class")).thenReturn("mat-disabled");
when(component.getDomAttribute("class")).thenReturn("mat-disabled");
assertTrue(testSubject.isDisabled(component));
}

Expand All @@ -155,8 +155,8 @@ void isDisabled3() {
WebElement element = mock(WebElement.class);
when(component.getWrappedElement()).thenReturn(element);
when(element.isEnabled()).thenReturn(true);
when(component.getAttribute("class")).thenReturn("");
when(component.getAttribute("aria-disabled")).thenReturn("true");
when(component.getDomAttribute("class")).thenReturn("");
when(component.getDomAttribute("aria-disabled")).thenReturn("true");
assertTrue(testSubject.isDisabled(component));
}

Expand All @@ -166,7 +166,7 @@ void isDisabled4() {
WebElement element = mock(WebElement.class);
when(component.getWrappedElement()).thenReturn(element);
when(element.isEnabled()).thenReturn(true);
when(component.getAttribute("class")).thenReturn("");
when(component.getDomAttribute("class")).thenReturn("");
assertFalse(testSubject.isDisabled(component));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ void setUp() {

@Test
void validate() {
when(element.getAttribute("class")).thenReturn("mat-accordion");
when(element.getDomAttribute("class")).thenReturn("mat-accordion");
assertTrue(testSubject.validate());
}

@Test
void validateFalse() {
when(element.getAttribute("class")).thenReturn("mat-accordion-333");
when(element.getDomAttribute("class")).thenReturn("mat-accordion-333");
assertFalse(testSubject.validate());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,56 +461,56 @@ void selectByValueWithDelays() {

@Test
void deselectAll() {
when(inputElement.getAttribute("value")).thenReturn("Option 2");
when(inputElement.getDomAttribute("value")).thenReturn("Option 2");
testSubject.deselectAll();
verify(inputElement, times(8)).sendKeys(BACK_SPACE);
}

@Test
void deselectAllWithDelays() {
when(inputElement.getAttribute("value")).thenReturn("Option 2");
when(inputElement.getDomAttribute("value")).thenReturn("Option 2");
testSubject.deselectAll(1000L);
verify(inputElement, times(8)).sendKeys(BACK_SPACE);
}

@Test
void deselectByValue() {
when(inputElement.getAttribute("value")).thenReturn("Option 2");
when(inputElement.getDomAttribute("value")).thenReturn("Option 2");
testSubject.deselectByValue(null);
verify(inputElement, times(8)).sendKeys(BACK_SPACE);
}

@Test
void deselectByValueWithDelays() {
when(inputElement.getAttribute("value")).thenReturn("Option 2");
when(inputElement.getDomAttribute("value")).thenReturn("Option 2");
testSubject.deselectByValue(null, 1000L);
verify(inputElement, times(8)).sendKeys(BACK_SPACE);
}

@Test
void deselectByIndex() {
when(inputElement.getAttribute("value")).thenReturn("Option 2");
when(inputElement.getDomAttribute("value")).thenReturn("Option 2");
testSubject.deselectByIndex(1);
verify(inputElement, times(8)).sendKeys(BACK_SPACE);
}

@Test
void deselectByIndexWithDelays() {
when(inputElement.getAttribute("value")).thenReturn("Option 2");
when(inputElement.getDomAttribute("value")).thenReturn("Option 2");
testSubject.deselectByIndex(1, 1000L);
verify(inputElement, times(8)).sendKeys(BACK_SPACE);
}

@Test
void deselectByVisibleText() {
when(inputElement.getAttribute("value")).thenReturn("Option 2");
when(inputElement.getDomAttribute("value")).thenReturn("Option 2");
testSubject.deselectByVisibleText(null);
verify(inputElement, times(8)).sendKeys(BACK_SPACE);
}

@Test
void deselectByVisibleTextWithDelays() {
when(inputElement.getAttribute("value")).thenReturn("Option 2");
when(inputElement.getDomAttribute("value")).thenReturn("Option 2");
testSubject.deselectByVisibleText(null, 1000L);
verify(inputElement, times(8)).sendKeys(BACK_SPACE);
}
Expand Down Expand Up @@ -560,14 +560,14 @@ void testToString() {
@Test
void validate() {
when(config.getCssPrefix()).thenReturn("mat-");
when(element.getAttribute("class")).thenReturn("mat-autocomplete-trigger");
when(element.getDomAttribute("class")).thenReturn("mat-autocomplete-trigger");
assertTrue(testSubject.validate());
}

@Test
void validateFalse() {
when(config.getCssPrefix()).thenReturn("mat-");
when(element.getAttribute("class")).thenReturn("mat-autocomplete-trigger-some-other");
when(element.getDomAttribute("class")).thenReturn("mat-autocomplete-trigger-some-other");
assertFalse(testSubject.validate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ void getComponentName() {

@Test
void validate() {
when(element.getAttribute("class")).thenReturn("mat-badge");
when(element.getDomAttribute("class")).thenReturn("mat-badge");
assertTrue(testSubject.validate());
}

@Test
void validateFalse() {
when(element.getAttribute("class")).thenReturn("");
when(element.getDomAttribute("class")).thenReturn("");
assertFalse(testSubject.validate());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ void getComponentName() {

@Test
void validate() {
when(element.getAttribute("class")).thenReturn("mat-bottom-sheet-container");
when(element.getDomAttribute("class")).thenReturn("mat-bottom-sheet-container");
assertTrue(testSubject.validate());
}

@Test
void validateFalse() {
when(element.getAttribute("class")).thenReturn("mat-bottom-sheet-container-123");
when(element.getDomAttribute("class")).thenReturn("mat-bottom-sheet-container-123");
assertFalse(testSubject.validate());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ void getComponentName() {

@Test
void validate() {
when(element.getAttribute("class")).thenReturn("mat-button-base");
when(element.getDomAttribute("class")).thenReturn("mat-button-base");
assertTrue(testSubject.validate());
}

@Test
void validateFalse() {
when(element.getAttribute("class")).thenReturn("mat-button-base-123");
when(element.getDomAttribute("class")).thenReturn("mat-button-base-123");
assertFalse(testSubject.validate());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ void getComponentName() {

@Test
void validate() {
when(element.getAttribute("class")).thenReturn("mat-button-toggle-group 123");
when(element.getDomAttribute("class")).thenReturn("mat-button-toggle-group 123");
assertTrue(testSubject.validate());
}

@Test
void validateFalse() {
when(element.getAttribute("class")).thenReturn("mat-button-toggle-group-123 123");
when(element.getDomAttribute("class")).thenReturn("mat-button-toggle-group-123 123");
assertFalse(testSubject.validate());
}

Expand Down
Loading

0 comments on commit dec0dc3

Please sign in to comment.