@@ -7,42 +7,45 @@ test('works with signal inputs', async () => {
7
7
inputs : {
8
8
...aliasedInput ( 'greeting' , 'Hello' ) ,
9
9
name : 'world' ,
10
+ age : '45' ,
10
11
} ,
11
12
} ) ;
12
13
13
14
const inputValue = within ( screen . getByTestId ( 'input-value' ) ) ;
14
- expect ( inputValue . getByText ( / h e l l o w o r l d / i) ) . toBeInTheDocument ( ) ;
15
+ expect ( inputValue . getByText ( / h e l l o w o r l d o f 4 5 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
15
16
} ) ;
16
17
17
18
test ( 'works with computed' , async ( ) => {
18
19
await render ( SignalInputComponent , {
19
20
inputs : {
20
21
...aliasedInput ( 'greeting' , 'Hello' ) ,
21
22
name : 'world' ,
23
+ age : '45' ,
22
24
} ,
23
25
} ) ;
24
26
25
27
const computedValue = within ( screen . getByTestId ( 'computed-value' ) ) ;
26
- expect ( computedValue . getByText ( / h e l l o w o r l d / i) ) . toBeInTheDocument ( ) ;
28
+ expect ( computedValue . getByText ( / h e l l o w o r l d o f 4 5 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
27
29
} ) ;
28
30
29
31
test ( 'can update signal inputs' , async ( ) => {
30
32
const { fixture } = await render ( SignalInputComponent , {
31
33
inputs : {
32
34
...aliasedInput ( 'greeting' , 'Hello' ) ,
33
35
name : 'world' ,
36
+ age : '45' ,
34
37
} ,
35
38
} ) ;
36
39
37
40
const inputValue = within ( screen . getByTestId ( 'input-value' ) ) ;
38
41
const computedValue = within ( screen . getByTestId ( 'computed-value' ) ) ;
39
42
40
- expect ( inputValue . getByText ( / h e l l o w o r l d / i) ) . toBeInTheDocument ( ) ;
43
+ expect ( inputValue . getByText ( / h e l l o w o r l d o f 4 5 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
41
44
42
45
fixture . componentInstance . name . set ( 'updated' ) ;
43
46
// set doesn't trigger change detection within the test, findBy is needed to update the template
44
- expect ( await inputValue . findByText ( / h e l l o u p d a t e d / i) ) . toBeInTheDocument ( ) ;
45
- expect ( await computedValue . findByText ( / h e l l o u p d a t e d / i) ) . toBeInTheDocument ( ) ;
47
+ expect ( await inputValue . findByText ( / h e l l o u p d a t e d o f 4 5 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
48
+ expect ( await computedValue . findByText ( / h e l l o u p d a t e d o f 4 5 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
46
49
47
50
// it's not recommended to access the model directly, but it's possible
48
51
expect ( fixture . componentInstance . name ( ) ) . toBe ( 'updated' ) ;
@@ -54,6 +57,7 @@ test('output emits a value', async () => {
54
57
inputs : {
55
58
...aliasedInput ( 'greeting' , 'Hello' ) ,
56
59
name : 'world' ,
60
+ age : '45' ,
57
61
} ,
58
62
on : {
59
63
submit : submitFn ,
@@ -70,6 +74,7 @@ test('model update also updates the template', async () => {
70
74
inputs : {
71
75
...aliasedInput ( 'greeting' , 'Hello' ) ,
72
76
name : 'initial' ,
77
+ age : '45' ,
73
78
} ,
74
79
} ) ;
75
80
@@ -100,22 +105,24 @@ test('works with signal inputs, computed values, and rerenders', async () => {
100
105
inputs : {
101
106
...aliasedInput ( 'greeting' , 'Hello' ) ,
102
107
name : 'world' ,
108
+ age : '45' ,
103
109
} ,
104
110
} ) ;
105
111
106
112
const inputValue = within ( screen . getByTestId ( 'input-value' ) ) ;
107
113
const computedValue = within ( screen . getByTestId ( 'computed-value' ) ) ;
108
114
109
- expect ( inputValue . getByText ( / h e l l o w o r l d / i) ) . toBeInTheDocument ( ) ;
110
- expect ( computedValue . getByText ( / h e l l o w o r l d / i) ) . toBeInTheDocument ( ) ;
115
+ expect ( inputValue . getByText ( / h e l l o w o r l d o f 4 5 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
116
+ expect ( computedValue . getByText ( / h e l l o w o r l d o f 4 5 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
111
117
112
118
await view . rerender ( {
113
119
inputs : {
114
120
...aliasedInput ( 'greeting' , 'bye' ) ,
115
121
name : 'test' ,
122
+ age : '0' ,
116
123
} ,
117
124
} ) ;
118
125
119
- expect ( inputValue . getByText ( / b y e t e s t / i) ) . toBeInTheDocument ( ) ;
120
- expect ( computedValue . getByText ( / b y e t e s t / i) ) . toBeInTheDocument ( ) ;
126
+ expect ( inputValue . getByText ( / b y e t e s t o f 0 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
127
+ expect ( computedValue . getByText ( / b y e t e s t o f 0 y e a r s o l d / i) ) . toBeInTheDocument ( ) ;
121
128
} ) ;
0 commit comments