test: 💍 add tests for adapter and serializer scope options

This commit is contained in:
Randall Morey committed 2020-09-03 14:48:59 -04:00
1 parent bce27df1f4
commit 2eeb73b622
6 files changed
+76 -8

No files matched your search

@@ -29,6 +29,48 @@ module('Unit | Serializer | application', function (hooks) {
});
});
test('it does not serialize scope_id when serializeScopeID is false', function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('user');
const record = store.createRecord('user', {
name: 'User',
description: 'Description',
scope: {
scope_id: 'global',
type: 'global'
}
});
const serializedRecord = record.serialize();
assert.equal(serializer.serializeScopeID, false);
assert.deepEqual(serializedRecord, {
name: 'User',
description: 'Description'
});
});
test('it does serialize scope_id when serializeScopeID is true', function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('user');
serializer.serializeScopeID = true;
const record = store.createRecord('user', {
name: 'User',
description: 'Description',
scope: {
scope_id: 'global',
type: 'global'
}
});
const serializedRecord = record.serialize();
assert.equal(serializer.serializeScopeID, true);
assert.deepEqual(serializedRecord, {
name: 'User',
description: 'Description',
scope_id: 'global'
});
});
test('it serializes non-nullish version fields', function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');