Joachim Van Herwegen b3da9c9fcf refactor: Restructure source code folder
This way the location of certain classes should make more sense
2021-10-12 12:51:02 +02:00

18 lines
662 B
TypeScript

import type { Operation } from '../../../../../../src/http/Operation';
import { BasicRepresentation } from '../../../../../../src/http/representation/BasicRepresentation';
/**
* Creates a mock HttpRequest which is a stream of an object encoded as application/json
* and a matching content-type header.
* @param data - Object to encode.
* @param url - URL value of the request.
*/
export function createPostJsonOperation(data: NodeJS.Dict<any>, url?: string): Operation {
return {
method: 'POST',
preferences: {},
target: { path: url ?? 'http://test.com/' },
body: new BasicRepresentation(JSON.stringify(data), 'application/json'),
};
}