How to use the @stoplight/prism-http/mocker/negotiator/__tests__/utils.anHttpOperation function in @stoplight/prism-http

To help you get started, we’ve selected a few @stoplight/prism-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stoplightio / prism / packages / http / src / mocker / negotiator / __tests__ / HttpOperationOptionsNegotiator.spec.ts View on Github external
describe('negotiate()', () => {
    const httpOperationConfig = {
      code: chance.string(),
      mediaType: chance.string(),
      exampleKey: chance.string(),
      dynamic: chance.bool()
    };
    const httpRequest: IHttpRequest = {
      method: 'get',
      path: '',
      host: ''
    };
    const desiredConfig = {};
    const httpOperation = anHttpOperation().instance();

    function getOpts(resource: any, input: any, config: any) {
      return { resource, input, config };
    }

    describe('given valid input', () => {
      it('and negotiations succeed should return config', async () => {
        jest.spyOn(helpers, 'negotiateOptionsForValidRequest').mockReturnValue(httpOperationConfig);

        const result = await negotiator.negotiate(getOpts(httpOperation, {
          data: httpRequest,
          validations: {
            input: []
          }
        }, desiredConfig));