File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
src/LiveComponent/assets/test Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -630,4 +630,23 @@ describe('LiveController rendering Tests', () => {
630
630
// verify the selectedIndex of the select option 2 is 0
631
631
expect ( selectOption2 . selectedIndex ) . toBe ( 0 ) ;
632
632
} ) ;
633
+
634
+ it ( 'backend will have a new csrf token' , async ( ) => {
635
+ const test = await createTest (
636
+ { } ,
637
+ ( data : any ) => `
638
+ <div ${ initComponent ( data ) } data-live-csrf-value="${ data . csrf } ">
639
+ </div>
640
+ `
641
+ ) ;
642
+
643
+ test . expectsAjaxCall ( ) . serverWillChangeProps ( ( data : any ) => {
644
+ // change csrf token
645
+ data . csrf = 'Hello' ;
646
+ } ) ;
647
+
648
+ await test . component . render ( ) ;
649
+
650
+ expect ( test . mockedBackend . csrfToken ) . toEqual ( 'Hello' ) ;
651
+ } ) ;
633
652
} ) ;
Original file line number Diff line number Diff line change @@ -98,6 +98,8 @@ class FunctionalTest {
98
98
class MockedBackend implements BackendInterface {
99
99
private expectedMockedAjaxCalls : Array < MockedAjaxCall > = [ ] ;
100
100
101
+ public csrfToken : string | null = null ;
102
+
101
103
addMockedAjaxCall ( mock : MockedAjaxCall ) {
102
104
this . expectedMockedAjaxCalls . push ( mock ) ;
103
105
}
@@ -139,6 +141,10 @@ class MockedBackend implements BackendInterface {
139
141
return matchedMock . createBackendRequest ( ) ;
140
142
}
141
143
144
+ updateCsrfToken ( csrfToken : string ) {
145
+ this . csrfToken = csrfToken ;
146
+ }
147
+
142
148
getExpectedMockedAjaxCalls ( ) : Array < MockedAjaxCall > {
143
149
return this . expectedMockedAjaxCalls ;
144
150
}
You can’t perform that action at this time.
0 commit comments