open-vault/ui/tests/helpers/mirage-to-models.js
Jordan Reimer e733c78ff6
Secrets header version badge (#13015)
* updates secret list header to display badge for all versions

* adds changelog entry

* updates secret list header to only show badge for kv and generic engine types

* adds secret-engine mirage factory

* adds test helper for pushing serialized mirage data into store and returning ember data models

* adds secret engine type version badge display test

* updates mirage application serializer to return singular type key
2021-11-08 14:29:00 -07:00

13 lines
465 B
JavaScript

import { getContext } from '@ember/test-helpers';
export default data => {
const context = getContext();
const store = context.owner.lookup('service:store');
const modelName = Array.isArray(data) ? data[0].modelName : data.modelName;
const json = context.server.serializerOrRegistry.serialize(data);
store.push(json);
return Array.isArray(data)
? data.map(({ id }) => store.peekRecord(modelName, id))
: store.peekRecord(modelName, data.id);
};