@@ -51,6 +51,20 @@ test('Counter actions via template syntax with parameters', async () => {
5151} ) ;
5252
5353test ( '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 ( ) => {
5468 const { getByText, getByTestId, click } = await render ( CounterComponent , {
5569 declarations : [ CounterComponent ] ,
5670 componentProperties : {
@@ -67,16 +81,18 @@ test('Counter actions via component syntax', async () => {
6781 expect ( getByTestId ( 'count' ) . textContent ) . toBe ( 'Current Count: 10' ) ;
6882} ) ;
6983
70- test ( 'Counter actions via component syntax without parameters ' , async ( ) => {
84+ test ( 'Counter actions via component syntax without declaration ' , async ( ) => {
7185 const { getByText, getByTestId, click } = await render ( CounterComponent , {
72- declarations : [ CounterComponent ] ,
86+ componentProperties : {
87+ counter : 10 ,
88+ } ,
7389 } ) ;
7490
7591 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 ' ) ;
7894
7995 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 ' ) ;
8298} ) ;
0 commit comments