2019-06-25 20:57:50 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupTest } from 'ember-qunit';
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
module('Unit | Adapter | kmip/role', function (hooks) {
|
2019-06-25 20:57:50 +00:00
|
|
|
setupTest(hooks);
|
|
|
|
|
|
|
|
let serializeTests = [
|
|
|
|
[
|
2019-07-02 21:23:07 +00:00
|
|
|
'operation_all is the only operation item present after serialization',
|
|
|
|
{
|
|
|
|
serialize() {
|
|
|
|
return { operation_all: true, operation_get: true, operation_create: true, tls_ttl: '10s' };
|
|
|
|
},
|
|
|
|
record: {
|
|
|
|
nonOperationFields: ['tlsTtl'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
operation_all: true,
|
|
|
|
tls_ttl: '10s',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'serialize does not include nonOperationFields values if they are not set',
|
2019-06-25 20:57:50 +00:00
|
|
|
{
|
|
|
|
serialize() {
|
|
|
|
return { operation_all: true, operation_get: true, operation_create: true };
|
|
|
|
},
|
2019-07-02 21:23:07 +00:00
|
|
|
record: {
|
|
|
|
nonOperationFields: ['tlsTtl'],
|
|
|
|
},
|
2019-06-25 20:57:50 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
operation_all: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
2019-07-02 21:23:07 +00:00
|
|
|
'operation_none is the only operation item present after serialization',
|
2019-06-25 20:57:50 +00:00
|
|
|
{
|
|
|
|
serialize() {
|
2019-07-02 21:23:07 +00:00
|
|
|
return { operation_none: true, operation_get: true, operation_add_attribute: true, tls_ttl: '10s' };
|
|
|
|
},
|
|
|
|
record: {
|
|
|
|
nonOperationFields: ['tlsTtl'],
|
2019-06-25 20:57:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
operation_none: true,
|
2019-07-02 21:23:07 +00:00
|
|
|
tls_ttl: '10s',
|
2019-06-25 20:57:50 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'operation_all and operation_none are removed if not truthy',
|
|
|
|
{
|
|
|
|
serialize() {
|
|
|
|
return {
|
|
|
|
operation_all: false,
|
|
|
|
operation_none: false,
|
|
|
|
operation_get: true,
|
|
|
|
operation_add_attribute: true,
|
|
|
|
operation_destroy: true,
|
|
|
|
};
|
|
|
|
},
|
2019-07-02 21:23:07 +00:00
|
|
|
record: {
|
|
|
|
nonOperationFields: ['tlsTtl'],
|
|
|
|
},
|
2019-06-25 20:57:50 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
operation_get: true,
|
|
|
|
operation_add_attribute: true,
|
|
|
|
operation_destroy: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
];
|
|
|
|
for (let testCase of serializeTests) {
|
|
|
|
let [name, snapshotStub, expected] = testCase;
|
2021-12-17 03:44:29 +00:00
|
|
|
test(`adapter serialize: ${name}`, function (assert) {
|
2019-06-25 20:57:50 +00:00
|
|
|
let adapter = this.owner.lookup('adapter:kmip/role');
|
|
|
|
let result = adapter.serialize(snapshotStub);
|
|
|
|
assert.deepEqual(result, expected, 'output matches expected');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|