open-vault/ui/tests/unit/adapters/kmip/role-test.js
Matthew Irish ddf8c20219
UI - add delete for the various kmip models (#7015)
* add menu-loader component to show menu loading button when the model relationship isPending

* list what keys we've got in api-path error

* fix spacing issue on error flash

* add an action on list-controller that bubbles to the list-route mixin to refresh the route

* empty store when creating scopes

* don't delete _requestQuery in the loop, do it after

* add scope deletion from the scope list

* add deleteRecord to kmip adapters

* add model-wrap component

* delete role from detail page and list

* add revoke credentials functionality

* fix comment

* treat all operations fields specially on kmip roles

* adjust kmip role edit form for new fields

* fix api-path test

* update document blocks for menu-loader and model-wrap components
2019-07-02 16:23:07 -05:00

84 lines
2.1 KiB
JavaScript

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Adapter | kmip/role', function(hooks) {
setupTest(hooks);
let serializeTests = [
[
'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',
{
serialize() {
return { operation_all: true, operation_get: true, operation_create: true };
},
record: {
nonOperationFields: ['tlsTtl'],
},
},
{
operation_all: true,
},
],
[
'operation_none is the only operation item present after serialization',
{
serialize() {
return { operation_none: true, operation_get: true, operation_add_attribute: true, tls_ttl: '10s' };
},
record: {
nonOperationFields: ['tlsTtl'],
},
},
{
operation_none: true,
tls_ttl: '10s',
},
],
[
'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,
};
},
record: {
nonOperationFields: ['tlsTtl'],
},
},
{
operation_get: true,
operation_add_attribute: true,
operation_destroy: true,
},
],
];
for (let testCase of serializeTests) {
let [name, snapshotStub, expected] = testCase;
test(`adapter serialize: ${name}`, function(assert) {
let adapter = this.owner.lookup('adapter:kmip/role');
let result = adapter.serialize(snapshotStub);
assert.deepEqual(result, expected, 'output matches expected');
});
}
});