Skip to content

Commit 8dd14c7

Browse files
author
Robert Jackson
committed
Avoid using @tracked in tests when it isn't available
1 parent 94b3132 commit 8dd14c7

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

tests/integration/modifiers/did-update-test.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { setupRenderingTest } from 'ember-qunit';
44
import { render, settled } from '@ember/test-helpers';
55
import hbs from 'htmlbars-inline-precompile';
66

7+
import { macroCondition, dependencySatisfies } from '@embroider/macros';
8+
79
module('Integration | Modifier | did-update', function (hooks) {
810
setupRenderingTest(hooks);
911

@@ -26,27 +28,30 @@ module('Integration | Modifier | did-update', function (hooks) {
2628
this.set('boundValue', 'update');
2729
});
2830

29-
test('it consumes tracked properties without re-invoking', async function (assert) {
30-
assert.expect(1);
31+
// only run the next test where @tracked is present
32+
if (macroCondition(dependencySatisfies('ember-source', '>= 3.12.0'))) {
33+
test('it consumes tracked properties without re-invoking', async function (assert) {
34+
assert.expect(1);
3135

32-
class Context {
33-
@tracked boundValue = 'initial';
34-
@tracked secondaryValue = 'initial';
35-
}
36+
class Context {
37+
@tracked boundValue = 'initial';
38+
@tracked secondaryValue = 'initial';
39+
}
3640

37-
this.context = new Context();
41+
this.context = new Context();
3842

39-
this.someMethod = () => {
40-
// This assertion works as an assurance that we render before `secondaryValue` changes,
41-
// and consumes its tag to ensure reading tracked properties won't re-trigger the modifier
42-
assert.equal(this.context.secondaryValue, 'initial');
43-
};
43+
this.someMethod = () => {
44+
// This assertion works as an assurance that we render before `secondaryValue` changes,
45+
// and consumes its tag to ensure reading tracked properties won't re-trigger the modifier
46+
assert.equal(this.context.secondaryValue, 'initial');
47+
};
4448

45-
await render(hbs`<div {{did-update this.someMethod this.context.boundValue}}></div>`);
49+
await render(hbs`<div {{did-update this.someMethod this.context.boundValue}}></div>`);
4650

47-
this.context.boundValue = 'update';
48-
await settled();
49-
this.context.secondaryValue = 'update';
50-
await settled();
51-
});
51+
this.context.boundValue = 'update';
52+
await settled();
53+
this.context.secondaryValue = 'update';
54+
await settled();
55+
});
56+
}
5257
});

0 commit comments

Comments
 (0)