File tree 1 file changed +33
-0
lines changed 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,39 @@ describe('data', function () {
92
92
} )
93
93
} )
94
94
95
+ it ( 'waitForData + promise sugar' , function ( done ) {
96
+ test ( {
97
+ data : {
98
+ waitForData : true ,
99
+ data : function ( transition ) {
100
+ return {
101
+ msg : new Promise ( function ( resolve ) {
102
+ setTimeout ( function ( ) {
103
+ resolve ( transition . to . params . msg )
104
+ } , wait )
105
+ } )
106
+ }
107
+ }
108
+ }
109
+ } , function ( router , calls ) {
110
+ router . go ( '/data/hello' )
111
+ assertCalls ( calls , [ 'data.data' ] )
112
+ expect ( router . app . $el . textContent ) . toBe ( '' )
113
+ setTimeout ( function ( ) {
114
+ expect ( router . app . $el . textContent ) . toBe ( 'hello' )
115
+ router . go ( '/data/reload' )
116
+ assertCalls ( calls , [ 'data.data' , 'data.data' ] )
117
+ router . app . $nextTick ( function ( ) {
118
+ expect ( router . app . $el . textContent ) . toBe ( 'loading...' )
119
+ setTimeout ( function ( ) {
120
+ expect ( router . app . $el . textContent ) . toBe ( 'reload' )
121
+ done ( )
122
+ } , wait * 2 )
123
+ } )
124
+ } , wait * 2 )
125
+ } )
126
+ } )
127
+
95
128
it ( 'promise error' , function ( done ) {
96
129
test ( {
97
130
data : {
You can’t perform that action at this time.
0 commit comments