Files
threshold-ui/addons/api/tests/unit/serializers/fragment-principal-test.js
T

30 lines
850 B
JavaScript
Raw Normal View History

2020-08-12 13:41:23 -04:00
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import FragmentPrincipal from 'api/models/fragment-principal';
2020-09-16 14:29:02 -04:00
module('Unit | Serializer | fragment principal', function (hooks) {
2020-08-12 13:41:23 -04:00
setupTest(hooks);
2020-09-16 14:29:02 -04:00
test('it normalizes `id` into `principal_id`', function (assert) {
2020-08-12 13:41:23 -04:00
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('fragment-principal');
const normalized = serializer.normalize(FragmentPrincipal, {
scope_id: '1',
principal_id: '2',
2020-09-16 14:29:02 -04:00
type: 'user',
2020-08-12 13:41:23 -04:00
});
assert.deepEqual(normalized, {
data: {
attributes: {
scope_id: '1',
principal_id: '2',
2020-09-16 14:29:02 -04:00
type: 'user',
2020-08-12 13:41:23 -04:00
},
id: null,
relationships: {},
2020-09-16 14:29:02 -04:00
type: 'fragment-principal',
},
2020-08-12 13:41:23 -04:00
});
});
});