How to use the @stoplight/prism-core/src/__tests__/utils.assertResolvesLeft function in @stoplight/prism-core

To help you get started, we’ve selected a few @stoplight/prism-core 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 / utils / __tests__ / parseResponse.spec.ts View on Github external
it('returns error', async () => {
        const response = {
          headers: new Headers({ 'content-type': 'application/json' }),
          json: jest.fn().mockRejectedValue(new Error('Big Bada Boom')),
          text: jest.fn(),
        };

        await assertResolvesLeft(parseResponseBody(response), error => expect(error.message).toEqual('Big Bada Boom'));

        expect(response.text).not.toHaveBeenCalled();
      });
    });
github stoplightio / prism / packages / http / src / utils / __tests__ / parseResponse.spec.ts View on Github external
it('returns error', () => {
      return assertResolvesLeft(
        parseResponse({
          status: 200,
          headers: new Headers(),
          json: jest.fn(),
          text: jest.fn().mockRejectedValue(new Error('Big Bada Boom')),
        }),
        error => {
          expect(error.message).toEqual('Big Bada Boom');
        }
      );
    });
  });
github stoplightio / prism / packages / http / src / __tests__ / http-prism-instance.spec.ts View on Github external
it(testText, () => {
            const op = prism.request(request, resources, config);
            errors
              ? assertResolvesLeft(op, e =>
                  expect(e).toMatchObject(ProblemJsonError.fromTemplate(NO_PATH_MATCHED_ERROR))
                )
              : assertResolvesRight(op);
          });
        });
github stoplightio / prism / packages / http / src / __tests__ / http-prism-instance.spec.ts View on Github external
it('returns an error if the the header is missing', () => {
      assertResolvesLeft(
        prism.request(
          {
            method: 'get',
            url: {
              path: '/pet/login',
            },
          },
          resources
        )
      );
    });
  });