Skip to content

Commit

Permalink
Add more tests until I found a failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
cibernox committed Aug 18, 2017
1 parent fb3bcaf commit 203a053
Showing 1 changed file with 126 additions and 0 deletions.
126 changes: 126 additions & 0 deletions packages/ember-glimmer/tests/integration/syntax/each-in-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,83 @@ if (typeof Map !== 'undefined') {
</ul>
`);
}

BasicSyntaxTest.prototype[`@test it can render duplicate items on ES6 Maps`] = function(assert) {
let map = new window.Map();
map.set('Smartphones', 8203);
map.set('Tablets', 8203);
map.set('JavaScript Frameworks', Infinity);
map.set('Bugs', Infinity);

this.render(strip`
<ul>
{{#each-in categories key='@identity' as |category count|}}
<li>{{category}}: {{count}}</li>
{{/each-in}}
</ul>
`, {
categories: map
});

this.assertHTML(strip`
<ul>
<li>Smartphones: 8203</li>
<li>Tablets: 8203</li>
<li>JavaScript Frameworks: Infinity</li>
<li>Bugs: Infinity</li>
</ul>
`);

this.assertStableRerender();

this.runTask(() => {
let map = new window.Map();
map.set('Smartphones', 100);
map.set('Tweets', 443115);
set(this.context, 'categories', map);
});

this.assertHTML(strip`
<ul>
<li>Smartphones: 100</li>
<li>Tweets: 443115</li>
</ul>
`);
}

BasicSyntaxTest.prototype[`@test it supports having objects as keys on the ES6 Maps`] = function(assert) {
let map = new window.Map();
map.set({ name: 'one' }, 'foo');
map.set({ name: 'two' }, 'bar');

this.render(strip`
<ul>
{{#each-in map key="@identity" as |key value|}}
<li>{{key.name}}: {{value}}</li>
{{/each-in}}
</ul>`, { map });

this.assertHTML(strip`
<ul>
<li>one: foo</li>
<li>two: bar</li>
</ul>
`);

this.assertStableRerender();

this.runTask(() => {
let map = new window.Map();
map.set({ name: 'three' }, 'qux');
set(this.context, 'map', map);
});

this.assertHTML(strip`
<ul>
<li>three: qux</li>
</ul>
`);
}
}

if (HAS_NATIVE_SYMBOL) {
Expand Down Expand Up @@ -678,6 +755,55 @@ if (HAS_NATIVE_SYMBOL) {
</ul>
`);
}

BasicSyntaxTest.prototype[`@test it can render duplicate items on an iterable`] = function(assert) {
let iterable = {
[Symbol.iterator]: () => makeIterator([
['Smartphones', '8203'],
['Tablets', '8203'],
['JavaScript Frameworks', Infinity],
['Bugs', Infinity]
])
};

this.render(strip`
<ul>
{{#each-in categories key='@identity' as |category count|}}
<li>{{category}}: {{count}}</li>
{{/each-in}}
</ul>
`, {
categories: iterable
});

this.assertHTML(strip`
<ul>
<li>Smartphones: 8203</li>
<li>Tablets: 8203</li>
<li>JavaScript Frameworks: Infinity</li>
<li>Bugs: Infinity</li>
</ul>
`);

this.assertStableRerender();

this.runTask(() => {
let iterable = {
[Symbol.iterator]: () => makeIterator([
['Smartphones', 100],
['Tweets', 443115]
])
};
set(this.context, 'categories', iterable);
});

this.assertHTML(strip`
<ul>
<li>Smartphones: 100</li>
<li>Tweets: 443115</li>
</ul>
`);
}
}

moduleFor('Syntax test: {{#each-in}}', BasicSyntaxTest);
Expand Down

0 comments on commit 203a053

Please sign in to comment.