@@ -51,6 +51,20 @@ test('Counter actions via template syntax with parameters', async () => {
51
51
} ) ;
52
52
53
53
test ( 'Counter actions via component syntax' , async ( ) => {
54
+ const { getByText, getByTestId, click } = await render ( CounterComponent , {
55
+ declarations : [ CounterComponent ] ,
56
+ } ) ;
57
+
58
+ click ( getByText ( '+' ) ) ;
59
+ expect ( getByText ( 'Current Count: 1' ) ) . toBeTruthy ( ) ;
60
+ expect ( getByTestId ( 'count' ) . textContent ) . toBe ( 'Current Count: 1' ) ;
61
+
62
+ click ( getByText ( '-' ) ) ;
63
+ expect ( getByText ( 'Current Count: 0' ) ) . toBeTruthy ( ) ;
64
+ expect ( getByTestId ( 'count' ) . textContent ) . toBe ( 'Current Count: 0' ) ;
65
+ } ) ;
66
+
67
+ test ( 'Counter actions via component syntax with parameters' , async ( ) => {
54
68
const { getByText, getByTestId, click } = await render ( CounterComponent , {
55
69
declarations : [ CounterComponent ] ,
56
70
componentProperties : {
@@ -67,16 +81,18 @@ test('Counter actions via component syntax', async () => {
67
81
expect ( getByTestId ( 'count' ) . textContent ) . toBe ( 'Current Count: 10' ) ;
68
82
} ) ;
69
83
70
- test ( 'Counter actions via component syntax without parameters ' , async ( ) => {
84
+ test ( 'Counter actions via component syntax without declaration ' , async ( ) => {
71
85
const { getByText, getByTestId, click } = await render ( CounterComponent , {
72
- declarations : [ CounterComponent ] ,
86
+ componentProperties : {
87
+ counter : 10 ,
88
+ } ,
73
89
} ) ;
74
90
75
91
click ( getByText ( '+' ) ) ;
76
- expect ( getByText ( 'Current Count: 1 ' ) ) . toBeTruthy ( ) ;
77
- expect ( getByTestId ( 'count' ) . textContent ) . toBe ( 'Current Count: 1 ' ) ;
92
+ expect ( getByText ( 'Current Count: 11 ' ) ) . toBeTruthy ( ) ;
93
+ expect ( getByTestId ( 'count' ) . textContent ) . toBe ( 'Current Count: 11 ' ) ;
78
94
79
95
click ( getByText ( '-' ) ) ;
80
- expect ( getByText ( 'Current Count: 0 ' ) ) . toBeTruthy ( ) ;
81
- expect ( getByTestId ( 'count' ) . textContent ) . toBe ( 'Current Count: 0 ' ) ;
96
+ expect ( getByText ( 'Current Count: 10 ' ) ) . toBeTruthy ( ) ;
97
+ expect ( getByTestId ( 'count' ) . textContent ) . toBe ( 'Current Count: 10 ' ) ;
82
98
} ) ;
0 commit comments