Skip to content

Commit 2ab8ec5

Browse files
committed
add test for interface default method access from template
1 parent deb6b1c commit 2ab8ec5

File tree

8 files changed

+34
-1
lines changed

8 files changed

+34
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.axellience.vuegwt.testsapp.client.common;
2+
3+
import jsinterop.annotations.JsMethod;
4+
5+
public interface InterfaceWithDefaultMethod {
6+
@JsMethod
7+
default String getDefaultText() {
8+
return "a default method value";
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.axellience.vuegwt.testsapp.client.common;
2+
3+
public class SimpleObjectWithDefaultMethod implements InterfaceWithDefaultMethod {
4+
}

tests/tests-app/src/main/java/com/axellience/vuegwt/testsapp/client/components/basic/data/DataTestComponent.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<li id='character-data'>{{ characterData }}</li>
2525
<li id='string-data'>{{ stringData }}</li>
2626
<li id='simple-object-data'>{{ simpleObjectData == null ? "" : simpleObjectData.getStringProperty() }}</li>
27+
<li id='default-method-on-data-object'>{{ simpleObjectWithDefaultMethod.getDefaultText() }}</li>
2728
<li id='string-starting-with-dollar'>{{ $dataStartingWithDollar }}</li>
2829
<li id='string-starting-with-underscore'>{{ _dataStartingWithUnderscore }}</li>
2930
</ul>

tests/tests-app/src/main/java/com/axellience/vuegwt/testsapp/client/components/basic/data/DataTestComponent.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.axellience.vuegwt.core.annotations.component.Data;
55
import com.axellience.vuegwt.core.client.component.IsVueComponent;
66
import com.axellience.vuegwt.testsapp.client.common.SimpleObject;
7+
import com.axellience.vuegwt.testsapp.client.common.SimpleObjectWithDefaultMethod;
78
import jsinterop.annotations.JsMethod;
89
import jsinterop.annotations.JsProperty;
910

@@ -64,6 +65,9 @@ public class DataTestComponent implements IsVueComponent {
6465
@Data
6566
SimpleObject simpleObjectData = null;
6667

68+
@Data
69+
SimpleObjectWithDefaultMethod simpleObjectWithDefaultMethod = new SimpleObjectWithDefaultMethod();
70+
6771
@Data
6872
String attributeValueData = null;
6973

tests/tests-app/src/main/java/com/axellience/vuegwt/testsapp/client/components/inheritance/ChildComponent.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
<div id="parentComputed">{{ parentComputed }}</div>
44
<div id="childData">{{ childData }}</div>
55
<div id="childComputed">{{ childComputed }}</div>
6+
<div id="parentInterfaceDefaultMethod">{{ getDefaultText() }}</div>
67
</div>

tests/tests-app/src/main/java/com/axellience/vuegwt/testsapp/client/components/inheritance/ChildComponent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import com.axellience.vuegwt.core.annotations.component.Component;
44
import com.axellience.vuegwt.core.annotations.component.Computed;
55
import com.axellience.vuegwt.core.annotations.component.Data;
6+
import com.axellience.vuegwt.testsapp.client.common.InterfaceWithDefaultMethod;
67
import jsinterop.annotations.JsMethod;
78

89
@Component
9-
public class ChildComponent extends ParentComponent {
10+
public class ChildComponent extends ParentComponent implements InterfaceWithDefaultMethod {
1011
@Data
1112
protected String childData = "CHILD_INITIAL_DATA";
1213

tests/tests-runner/src/test/javascript/components/basic/data.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ describe('Data', () => {
293293
});
294294
});
295295

296+
describe('simpleObjectWithDefaultMethod', () => {
297+
it('should display the value of the default method', async () => {
298+
const domValue = getElement(component, '#default-method-on-data-object').innerText;
299+
expect(domValue).to.equal('a default method value');
300+
});
301+
});
302+
296303
describe('attributeValueData', () => {
297304
it('should not be displayed in the DOM if its value is null', () => {
298305
const element = getElement(component, '#data-attribute-element');

tests/tests-runner/src/test/javascript/components/inheritance/inheritance.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ describe('Component inheritance', () => {
2727
'PARENT_INITIAL_DATA');
2828
});
2929

30+
it('should show result of interfaces default methods', () => {
31+
expect(getElement(component, "#parentInterfaceDefaultMethod").innerText).to.equal(
32+
'a default method value');
33+
});
34+
3035
it('should react to child data field change', async () => {
3136
expect(getElement(component, "#childData").innerText).to.equal(
3237
'CHILD_INITIAL_DATA');

0 commit comments

Comments
 (0)