1
+ /** eslint-disable @typescript-eslint/ban-ts-comment */
2
+ import { cached , tracked } from ' @glimmer/tracking' ;
3
+ import { render , settled } from ' @ember/test-helpers' ;
1
4
import { module , test } from ' qunit' ;
2
- import { setupTest } from ' ember-qunit' ;
5
+ import { setupRenderingTest , setupTest } from ' ember-qunit' ;
3
6
4
7
import { resource } from ' ember-resources' ;
5
8
@@ -14,7 +17,7 @@ module('RAW', function (hooks) {
14
17
15
18
compatOwner .setOwner (parent , this .owner );
16
19
17
- // @ts-expect-error - not sure what to bo about the type discrepency atm
20
+ // @ts-expect-error
18
21
let instance = thing .create ();
19
22
20
23
instance .link (parent );
@@ -25,7 +28,7 @@ module('RAW', function (hooks) {
25
28
let thing = resource (() => 2 );
26
29
27
30
assert .throws (() => {
28
- // @ts-expect-error - not sure what to bo about the type discrepency atm
31
+ // @ts-expect-error
29
32
let instance = thing .create ();
30
33
31
34
instance .current ;
@@ -36,7 +39,7 @@ module('RAW', function (hooks) {
36
39
let thing = resource (() => 2 );
37
40
38
41
assert .throws (() => {
39
- // @ts-expect-error - not sure what to bo about the type discrepency atm
42
+ // @ts-expect-error
40
43
let instance = thing .create ();
41
44
42
45
instance .link ({});
@@ -45,3 +48,38 @@ module('RAW', function (hooks) {
45
48
}, / Cannot link without an owner/ );
46
49
});
47
50
});
51
+
52
+ module (' RAW Rendering' , function (hooks ) {
53
+ setupRenderingTest (hooks );
54
+
55
+ test (' is reactive' , async function (assert ) {
56
+ class Context {
57
+ @tracked count = 0 ;
58
+
59
+ #thing = resource (() => this .count );
60
+
61
+ @cached
62
+ get thing() {
63
+ // @ts-expect-error
64
+ let instance = this .#thing .create ();
65
+
66
+ instance .link (this );
67
+
68
+ return instance ;
69
+ }
70
+ }
71
+
72
+ let ctx = new Context ();
73
+
74
+ compatOwner .setOwner (ctx , this .owner );
75
+
76
+ await render (<template >{{ctx.thing.current }} </template >);
77
+
78
+ assert .dom ().hasText (' 0' );
79
+
80
+ ctx .count ++ ;
81
+ await settled ();
82
+
83
+ assert .dom ().hasText (' 1' );
84
+ });
85
+ });
0 commit comments