Add update tests for serializer
This commit is contained in:
1 parent
d8aaddfcca
commit
bab8c8ea44
1 file changed
+79
@@ -113,4 +113,83 @@ module('Unit | Serializer | host catalog', function (hooks) {
|
||||
};
|
||||
assert.deepEqual(serializedRecord, expectedResult);
|
||||
});
|
||||
|
||||
test('it serializes aws correctly on update', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('host-catalog');
|
||||
store.push({
|
||||
data: {
|
||||
id: '1',
|
||||
type: 'host-catalog',
|
||||
attributes: {
|
||||
type: 'plugin',
|
||||
name: 'aws',
|
||||
description: 'test description',
|
||||
plugin: {
|
||||
name: 'aws',
|
||||
},
|
||||
region: 'andorra',
|
||||
access_key_id: 'foobars',
|
||||
secret_access_key: 'testing',
|
||||
},
|
||||
},
|
||||
});
|
||||
const record = store.peekRecord('host-catalog', '1');
|
||||
const snapshot = record._createSnapshot();
|
||||
const expectedResult = {
|
||||
type: 'plugin',
|
||||
name: 'aws',
|
||||
description: 'test description',
|
||||
attributes: {
|
||||
disable_credential_rotation: false,
|
||||
region: 'andorra',
|
||||
access_key_id: 'foobars',
|
||||
secret_access_key: 'testing',
|
||||
},
|
||||
};
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, expectedResult);
|
||||
});
|
||||
|
||||
test('it serializes azure correctly on update', function (assert) {
|
||||
assert.expect(1);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('host-catalog');
|
||||
store.push({
|
||||
data: {
|
||||
id: '2',
|
||||
type: 'host-catalog',
|
||||
attributes: {
|
||||
type: 'plugin',
|
||||
name: 'azure',
|
||||
description: 'test description',
|
||||
plugin: {
|
||||
name: 'azure',
|
||||
},
|
||||
tenant_id: 'a1b2c3',
|
||||
client_id: 'foobars12',
|
||||
subscription_id: 'barsfoo21',
|
||||
// these are Azure read-only fields and should NOT be included on update
|
||||
secret_id: 'secretBar12',
|
||||
secret_value: 'secretValue21',
|
||||
},
|
||||
},
|
||||
});
|
||||
const record = store.peekRecord('host-catalog', '2');
|
||||
const snapshot = record._createSnapshot();
|
||||
const expectedResult = {
|
||||
type: 'plugin',
|
||||
name: 'azure',
|
||||
description: 'test description',
|
||||
attributes: {
|
||||
disable_credential_rotation: false,
|
||||
tenant_id: 'a1b2c3',
|
||||
client_id: 'foobars12',
|
||||
subscription_id: 'barsfoo21',
|
||||
},
|
||||
};
|
||||
const serializedRecord = serializer.serialize(snapshot);
|
||||
assert.deepEqual(serializedRecord, expectedResult);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user