Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Glimmer2] Migrate and Remove block params test #13189

Merged
merged 1 commit into from
Apr 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,88 @@ moduleFor('Components test: curly components', class extends RenderingTest {
this.assertComponentElement(this.firstChild, { content: 'hello' });
}

['@test it can yield internal and external properties positionally']() {
let instance;

let FooBarComponent = Component.extend({
init() {
this._super(...arguments);
instance = this;
},
greeting: 'hello'
});

this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{yield greeting greetee.firstName}}' });

this.render('{{#foo-bar greetee=person as |greeting name|}}{{name}} {{person.lastName}}, {{greeting}}{{/foo-bar}}', {
person: {
firstName: 'Joel',
lastName: 'Kang'
}
});

this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' });

this.runTask(() => this.rerender());

this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' });

this.runTask(() => set(this.context, 'person', { firstName: 'Dora', lastName: 'the Explorer' }));

this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hello' });

this.runTask(() => set(instance, 'greeting', 'hola'));

this.assertComponentElement(this.firstChild, { content: 'Dora the Explorer, hola' });

this.runTask(() => {
set(instance, 'greeting', 'hello');
set(this.context, 'person', {
firstName: 'Joel',
lastName: 'Kang'
});
});

this.assertComponentElement(this.firstChild, { content: 'Joel Kang, hello' });
}

['@test #11519 - block param infinite loop']() {
let instance;
let FooBarComponent = Component.extend({
init() {
this._super(...arguments);
instance = this;
},
danger: 0
});

this.registerComponent('foo-bar', { ComponentClass: FooBarComponent, template: '{{danger}}{{yield danger}}' });

// On initial render, create streams. The bug will not have manifested yet, but at this point
// we have created streams that create a circular invalidation.
this.render(`{{#foo-bar as |dangerBlockParam|}}{{/foo-bar}}`);

this.assertText('0');

// Trigger a non-revalidating re-render. The yielded block will not be dirtied
// nor will block param streams, and thus no infinite loop will occur.
this.runTask(() => this.rerender());

this.assertText('0');

// Trigger a revalidation, which will cause an infinite loop without the fix
// in place. Note that we do not see the infinite loop is in testing mode,
// because a deprecation warning about re-renders is issued, which Ember
// treats as an exception.
this.runTask(() => set(instance, 'danger', 1));

this.assertText('1');

this.runTask(() => set(instance, 'danger', 0));

this.assertText('0');
}

['@test the component and its child components are destroyed'](assert) {
let destroyed = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0 };

Expand Down
56 changes: 56 additions & 0 deletions packages/ember-glimmer/tests/integration/syntax/with-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { set } from 'ember-metal/property_set';
import { A as emberA } from 'ember-runtime/system/native_array';
import { moduleFor, RenderingTest } from '../../utils/test-case';
import { TogglingSyntaxConditionalsTest } from '../../utils/shared-conditional-tests';
import { strip } from '../../utils/abstract-test-case';

moduleFor('Syntax test: {{#with}}', class extends TogglingSyntaxConditionalsTest {

Expand Down Expand Up @@ -292,4 +293,59 @@ moduleFor('Syntax test: Multiple {{#with as}} helpers', class extends RenderingT
this.assertText('Los Pivots');
}

['@test nested {{#with}} blocks should have access to root context']() {
this.render(strip`
{{name}}
{{#with committer1.name as |name|}}
[{{name}}
{{#with committer2.name as |name|}}
[{{name}}]
{{/with}}
{{name}}]
{{/with}}
{{name}}
{{#with committer2.name as |name|}}
[{{name}}
{{#with committer1.name as |name|}}
[{{name}}]
{{/with}}
{{name}}]
{{/with}}
{{name}}
`, {
name: 'ebryn',
committer1: { name: 'trek' },
committer2: { name: 'machty' }
});

this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn');

this.runTask(() => this.rerender());

this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn');

this.runTask(() => set(this.context, 'name', 'chancancode'));

this.assertText('chancancode[trek[machty]trek]chancancode[machty[trek]machty]chancancode');

this.runTask(() => set(this.context, 'committer1', { name: 'krisselden' }));

this.assertText('chancancode[krisselden[machty]krisselden]chancancode[machty[krisselden]machty]chancancode');

this.runTask(() => {
set(this.context, 'committer1.name', 'wycats');
set(this.context, 'committer2', { name: 'rwjblue' });
});

this.assertText('chancancode[wycats[rwjblue]wycats]chancancode[rwjblue[wycats]rwjblue]chancancode');

this.runTask(() => {
set(this.context, 'name', 'ebryn');
set(this.context, 'committer1', { name: 'trek' });
set(this.context, 'committer2', { name: 'machty' });
});

this.assertText('ebryn[trek[machty]trek]ebryn[machty[trek]machty]ebryn');
}

});
164 changes: 0 additions & 164 deletions packages/ember-htmlbars/tests/integration/block_params_test.js

This file was deleted.