File tree 2 files changed +54
-0
lines changed
test/runtime/samples/await-then-catch-if
2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ let fulfil ;
2
+
3
+ let thePromise = new Promise ( f => {
4
+ fulfil = f ;
5
+ } ) ;
6
+
7
+ export default {
8
+ data : {
9
+ show : true ,
10
+ thePromise
11
+ } ,
12
+
13
+ html : `
14
+ <p>loading...</p>
15
+ ` ,
16
+
17
+ test ( assert , component , target ) {
18
+ fulfil ( 42 ) ;
19
+
20
+ return thePromise
21
+ . then ( ( ) => {
22
+ assert . htmlEqual ( target . innerHTML , `
23
+ <p>the value is 42</p>
24
+ ` ) ;
25
+
26
+ component . set ( {
27
+ show : false
28
+ } ) ;
29
+
30
+ assert . htmlEqual ( target . innerHTML , `
31
+ <p>Else</p>
32
+ ` ) ;
33
+
34
+ component . set ( {
35
+ show : true
36
+ } ) ;
37
+
38
+ assert . htmlEqual ( target . innerHTML , `
39
+ <p>the value is 42</p>
40
+ ` ) ;
41
+ } ) ;
42
+ }
43
+ } ;
Original file line number Diff line number Diff line change
1
+ {{#if show}}
2
+ {{#await thePromise}}
3
+ < p > loading...</ p >
4
+ {{then theValue}}
5
+ < p > the value is {{theValue}}</ p >
6
+ {{catch theError}}
7
+ < p > oh no! {{theError.message}}</ p >
8
+ {{/await}}
9
+ {{else}}
10
+ < p > Else</ p >
11
+ {{/if}}
You can’t perform that action at this time.
0 commit comments