Skip to content

Commit

Permalink
add verification test for emberjs/ember.js#19162
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Oct 18, 2020
1 parent 1eb7c68 commit d2d310f
Showing 1 changed file with 65 additions and 4 deletions.
69 changes: 65 additions & 4 deletions tests/integration/modifiers/did-update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ module('Integration | Modifier | did-update', function(hooks) {

if (gte('3.22.0')) {
module('capabilities(3.22)', function() {
class Context {
@tracked boundValue = 'initial';
}

test('it basically works', async function(assert) {
assert.expect(5);

class Context {
@tracked boundValue = 'initial';
}


this.setProperties({
ctx: new Context() ,
someMethod(element, positional, named) {
Expand All @@ -43,6 +44,66 @@ module('Integration | Modifier | did-update', function(hooks) {

await settled();
});

test(
'emberjs/ember.js#19162 is resolved (destruction does not cause logical errors)',
async function(assert) {
// This test verifies https://github.com/emberjs/ember.js/issues/19162
// is fixed
//
let callCount = 0;

class Data {
@tracked someBool;
@tracked nestedData;

constructor(someBool, nestedData) {
this.someBool = someBool;
this.nestedData = nestedData;
}
}

this.setProperties({
data: new Data(true, new Data(true)),
someMethod(_element, positional, named) {
callCount++;

assert.equal(
positional[0].someBool,
true,
'value is always true, because the modifier is wrapped in an if condition'
);
assert.equal(
named.bool,
true,
'value is always true, because the modifier is wrapped in an if condition'
);
}
});

await render(
hbs`
{{#if this.data.someBool}}
<div data-foo="some-thing" {{did-update this.someMethod this.data bool=this.data.someBool}}>
</div>
{{/if}}
`
);

assert.equal(callCount, 0);

this.data.someBool = true;

await settled();

assert.equal(callCount, 1);

this.data.someBool = false;

await settled();

assert.equal(callCount, 1, `modifier's callback is not re-invoked`);
});
});
} else {
module('capabilities(3.13)', function() {
Expand Down

0 comments on commit d2d310f

Please sign in to comment.