Skip to content

Commit

Permalink
All group-by with strings that contain punctuation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sol Irvine authored and XiphiasUvella committed Jan 28, 2017
1 parent 988e7d1 commit 7dbcc57
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/helpers/group-by.js
Expand Up @@ -22,7 +22,7 @@ const groupFunction = function() {

if (!isEmberArray(group)) {
group = emberArray();
set(groups, groupName, group);
groups[`${groupName}`] = group;
}

group.push(item);
Expand Down
19 changes: 19 additions & 0 deletions tests/integration/helpers/group-by-test.js
Expand Up @@ -47,3 +47,22 @@ test('It watches for changes', function(assert) {

assert.equal(this.$().text().trim(), 'aabbccd', 'aabbccd is the right order');
});

test('It groups by properties that contain punctuation', function(assert) {
this.set('array', emberArray([
{ category: 'a, inc.', name: 'a' },
{ category: 'b, co.', name: 'b' },
{ category: 'c. l.l.p.', name: 'c' },
{ category: 'd & co.', name: 'd' }
]));

this.render(hbs`
{{~#each-in (group-by 'category' array) as |category entries|~}}
{{~category~}}
{{~#each entries as |entry|~}}{{~entry.name~}}{{~/each~}}
{{~/each-in~}}
`);

assert.equal(this.$().text().trim(), 'a, inc.ab, co.bc. l.l.p.cd & co.d', 'a, inc.ab, co.bc. l.l.p.cd & co.d is the right output');
});

0 comments on commit 7dbcc57

Please sign in to comment.