fix: 🐛 handle empty member_ids in group responses

This commit is contained in:
Randall Morey committed 2020-09-12 11:47:27 -04:00
1 parent bcd46cec1f
commit 156dc08ff5
3 files changed
+36 -2

No files matched your search

@@ -45,4 +45,34 @@ module('Unit | Serializer | group', function(hooks) {
});
});
test('it normalizes missing member_ids to empty array', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('group');
const group = store.createRecord('group').constructor;
const payload = {
id: '1',
name: 'Group 1',
scope: { id: 'o_123' }
};
const normalized = serializer.normalizeSingleResponse(
store,
group,
payload
);
assert.deepEqual(normalized, {
included: [],
data: {
id: '1',
type: 'group',
attributes: {
name: 'Group 1',
scope: { scope_id: 'o_123' },
member_ids: []
},
relationships: {},
},
});
});
});