From 2620607cc3588a209dae0d69e4fc81fc00ffeccd Mon Sep 17 00:00:00 2001 From: Carlos Alcaide Corvo Date: Mon, 1 Nov 2021 12:26:22 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Finish=20fragment=20seri?= =?UTF-8?q?alizer=20and=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finish fragment serializer and refactor the tests of the model to accomadate the change. --- .../fragment-managed-groups-attributes.js | 2 +- .../models/fragment-managed-groups-attributes.js | 1 + .../fragment-managed-groups-attributes.js | 1 + .../fragment-managed-groups-attributes-test.js | 13 +++++++++++++ .../fragment-managed-groups-attributes-test.js | 9 ++++----- .../tests/unit/serializers/managed-groups-test.js | 9 +++++++++ 6 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 addons/api/app/models/fragment-managed-groups-attributes.js create mode 100644 addons/api/app/serializers/fragment-managed-groups-attributes.js create mode 100644 addons/api/tests/unit/models/fragment-managed-groups-attributes-test.js diff --git a/addons/api/addon/serializers/fragment-managed-groups-attributes.js b/addons/api/addon/serializers/fragment-managed-groups-attributes.js index 750fb02fe..4d4ac0a4d 100644 --- a/addons/api/addon/serializers/fragment-managed-groups-attributes.js +++ b/addons/api/addon/serializers/fragment-managed-groups-attributes.js @@ -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]; diff --git a/addons/api/app/models/fragment-managed-groups-attributes.js b/addons/api/app/models/fragment-managed-groups-attributes.js new file mode 100644 index 000000000..491c0628f --- /dev/null +++ b/addons/api/app/models/fragment-managed-groups-attributes.js @@ -0,0 +1 @@ +export { default } from 'api/models/fragment-managed-groups-attributes'; diff --git a/addons/api/app/serializers/fragment-managed-groups-attributes.js b/addons/api/app/serializers/fragment-managed-groups-attributes.js new file mode 100644 index 000000000..1f10fec04 --- /dev/null +++ b/addons/api/app/serializers/fragment-managed-groups-attributes.js @@ -0,0 +1 @@ +export { default } from 'api/serializers/fragment-managed-groups-attributes'; diff --git a/addons/api/tests/unit/models/fragment-managed-groups-attributes-test.js b/addons/api/tests/unit/models/fragment-managed-groups-attributes-test.js new file mode 100644 index 000000000..3659b85e4 --- /dev/null +++ b/addons/api/tests/unit/models/fragment-managed-groups-attributes-test.js @@ -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); + }); +}); diff --git a/addons/api/tests/unit/serializers/fragment-managed-groups-attributes-test.js b/addons/api/tests/unit/serializers/fragment-managed-groups-attributes-test.js index c317d5771..f179021d3 100644 --- a/addons/api/tests/unit/serializers/fragment-managed-groups-attributes-test.js +++ b/addons/api/tests/unit/serializers/fragment-managed-groups-attributes-test.js @@ -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, + }); }); } ); diff --git a/addons/api/tests/unit/serializers/managed-groups-test.js b/addons/api/tests/unit/serializers/managed-groups-test.js index d19eac935..a072a37a0 100644 --- a/addons/api/tests/unit/serializers/managed-groups-test.js +++ b/addons/api/tests/unit/serializers/managed-groups-test.js @@ -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', + }, }); }); });