Skip to content

Commit b399ae0

Browse files
committed
Add rendering test
1 parent b1b9545 commit b399ae0

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

test-app/tests/core/raw-api-test.gts

+42-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
/** eslint-disable @typescript-eslint/ban-ts-comment */
2+
import { cached, tracked } from '@glimmer/tracking';
3+
import { render, settled } from '@ember/test-helpers';
14
import { module, test } from 'qunit';
2-
import { setupTest } from 'ember-qunit';
5+
import { setupRenderingTest, setupTest } from 'ember-qunit';
36

47
import { resource } from 'ember-resources';
58

@@ -14,7 +17,7 @@ module('RAW', function (hooks) {
1417

1518
compatOwner.setOwner(parent, this.owner);
1619

17-
// @ts-expect-error - not sure what to bo about the type discrepency atm
20+
// @ts-expect-error
1821
let instance = thing.create();
1922

2023
instance.link(parent);
@@ -25,7 +28,7 @@ module('RAW', function (hooks) {
2528
let thing = resource(() => 2);
2629

2730
assert.throws(() => {
28-
// @ts-expect-error - not sure what to bo about the type discrepency atm
31+
// @ts-expect-error
2932
let instance = thing.create();
3033

3134
instance.current;
@@ -36,7 +39,7 @@ module('RAW', function (hooks) {
3639
let thing = resource(() => 2);
3740

3841
assert.throws(() => {
39-
// @ts-expect-error - not sure what to bo about the type discrepency atm
42+
// @ts-expect-error
4043
let instance = thing.create();
4144

4245
instance.link({});
@@ -45,3 +48,38 @@ module('RAW', function (hooks) {
4548
}, /Cannot link without an owner/);
4649
});
4750
});
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

Comments
 (0)