[ICU-15403] Trim whitespace on storage buckets and host sets json attrs serializers (#2636)
* trim whitespace on json attrs in storage bucket serializer * add test for storage bucket serializer * move trimWhitespace check to application level * add trimWhitespace to preferred_endpoints attr * add conditional for string arr * trim whitespace on str arr * add check for null val * refactor, move logic * relocate comment * add unit test for application serializer
This commit is contained in:
1 parent
b287683a61
commit
e8cc22879f
7 files changed
+46
-5
No files matched your search
@@ -381,4 +381,29 @@ module('Unit | Serializer | application', function (hooks) {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// JSON values will only be trimmed if the model attr
|
||||
// includes the trimWhitespace property set to true
|
||||
// See preferred_endpoints attr on host-set model
|
||||
test('it trims whitespace on json values', function (assert) {
|
||||
const store = this.owner.lookup('service:store');
|
||||
const record = store.createRecord('host-set', {
|
||||
name: 'Host Set 1',
|
||||
compositeType: 'azure',
|
||||
description: 'Description',
|
||||
host_catalog_id: '123',
|
||||
version: 1,
|
||||
preferred_endpoints: [{ value: ' option 1' }, { value: 'option 2 ' }],
|
||||
sync_interval_seconds: 1,
|
||||
});
|
||||
assert.deepEqual(record.serialize(), {
|
||||
name: 'Host Set 1',
|
||||
description: 'Description',
|
||||
host_catalog_id: '123',
|
||||
version: 1,
|
||||
preferred_endpoints: ['option 1', 'option 2'],
|
||||
sync_interval_seconds: 1,
|
||||
attributes: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user