feat: 🎸 Finish fragment serializer and tests

Finish fragment serializer and refactor the tests of the model to
accomadate the change.
This commit is contained in:
Carlos Alcaide Corvo committed 2021-11-05 08:55:37 -07:00
1 parent 499432522a
commit 2620607cc3
6 files changed
+29 -6

No files matched your search

@@ -14,7 +14,7 @@ export default class FragmentManagedGroupsAttributesSerializer extends JSONSeria
serializeAttribute(snapshot, json, key, attribute) {
const { type, options } = attribute;
let value = super.serializeAttribute(...arguments);
// COnvert empty strin to null.
// Convert empty string to null.
if (type === 'string' && json[key] === '') json[key] = null;
// Do not serialize read-only attributes.
if (options.readOnly) delete json[key];
@@ -0,0 +1 @@
export { default } from 'api/models/fragment-managed-groups-attributes';
@@ -0,0 +1 @@
export { default } from 'api/serializers/fragment-managed-groups-attributes';
@@ -0,0 +1,13 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Model | fragment managed groups attributes', function (hooks) {
setupTest(hooks);
// Replace this with your real tests.
test('it exists', function (assert) {
let store = this.owner.lookup('service:store');
let model = store.createRecord('fragment-managed-groups-attributes', {});
assert.ok(model);
});
});
@@ -12,11 +12,10 @@ module(
const record = store.createRecord('fragment-managed-groups-attributes', {
filter: '',
});
// const serializedRecord = record.serialize();
// assert.deepEqual(serializedRecord, {
// filter: null,
// });
assert.equal(1, 1);
const serializedRecord = record.serialize();
assert.deepEqual(serializedRecord, {
filter: null,
});
});
}
);
@@ -25,6 +25,9 @@ module('Unit | Serializer | Managed groups', function (hooks) {
version: 1,
auth_method_id: '1234',
type: '80',
attributes: {
filter: 'OIDC',
},
});
});
@@ -43,6 +46,9 @@ module('Unit | Serializer | Managed groups', function (hooks) {
version: 1,
auth_method_id: '1234',
type: '80',
attributes: {
filter: 'key=value',
},
},
},
});
@@ -55,6 +61,9 @@ module('Unit | Serializer | Managed groups', function (hooks) {
version: 1,
auth_method_id: '1234',
type: '80',
attributes: {
filter: 'key=value',
},
});
});
});