2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2021-11-08 21:29:00 +00:00
|
|
|
import { getContext } from '@ember/test-helpers';
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
export default (data) => {
|
2021-11-08 21:29:00 +00:00
|
|
|
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);
|
|
|
|
};
|