Files
threshold-ui/addons/api/tests/unit/serializers/managed-groups-test.js
T

60 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-10-28 08:30:28 -07:00
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Serializer | Managed groups', function (hooks) {
setupTest(hooks);
2021-10-28 11:28:21 -07:00
test('it serializes correctly on create', function (assert) {
2021-10-28 08:30:28 -07:00
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('managed-groups');
const record = store.createRecord('managed-groups', {
name: 'Group',
description: 'Description',
member_ids: ['1', '2'],
version: 1,
auth_method_id: '1234',
type: '80',
});
const snapshot = record._createSnapshot();
snapshot.adapterOptions = {};
const serializedRecord = serializer.serialize(snapshot);
assert.deepEqual(serializedRecord, {
name: 'Group',
description: 'Description',
version: 1,
auth_method_id: '1234',
type: '80',
});
});
2021-10-28 11:28:21 -07:00
test('it serializes correctly on update', function (assert) {
2021-10-28 08:30:28 -07:00
assert.expect(1);
const store = this.owner.lookup('service:store');
const serializer = store.serializerFor('managed-groups');
2021-10-28 11:28:21 -07:00
store.push({
data: {
id: '1',
type: 'managed-groups',
attributes: {
name: 'Group Test',
description: 'Description for the test',
member_ids: ['1', '2'],
version: 1,
auth_method_id: '1234',
type: '80',
},
},
2021-10-28 08:30:28 -07:00
});
2021-10-28 11:28:21 -07:00
const record = store.peekRecord('managed-groups', '1');
2021-10-28 08:30:28 -07:00
const snapshot = record._createSnapshot();
const serializedRecord = serializer.serialize(snapshot);
assert.deepEqual(serializedRecord, {
2021-10-28 11:28:21 -07:00
name: 'Group Test',
description: 'Description for the test',
2021-10-28 08:30:28 -07:00
version: 1,
2021-10-28 11:28:21 -07:00
auth_method_id: '1234',
type: '80',
2021-10-28 08:30:28 -07:00
});
});
});