How to use the @stoplight/prism-core/src/__tests__/utils.assertResolvesRight 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 / __tests__ / http-prism-instance.spec.ts View on Github external
it('ignores server validation and returns 200', () => {
        assertResolvesRight(
          prism.request(
            {
              method: 'get',
              url: {
                path: '/pet',
              },
            },
            resources
          ),
          result => {
            expect(result.output).toBeDefined();
            expect(result.output.statusCode).toBe(200);
          }
        );
      });
    });
github stoplightio / prism / packages / http / src / utils / __tests__ / parseResponse.spec.ts View on Github external
it('returns body text', async () => {
      const response = {
        headers: new Headers(),
        json: jest.fn(),
        text: jest.fn().mockResolvedValue('Plavalaguna'),
      };

      await assertResolvesRight(parseResponseBody(response), body => expect(body).toEqual('Plavalaguna'));

      expect(response.json).not.toHaveBeenCalled();
    });
  });
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 / utils / __tests__ / parseResponse.spec.ts View on Github external
it('returns parsed response', () => {
      return assertResolvesRight(
        parseResponse({
          status: 200,
          headers: new Headers({ 'content-type': 'application/json', test: 'test' }),
          json: jest.fn().mockResolvedValue({ test: 'test' }),
          text: jest.fn(),
        }),
        response => {
          expect(response).toEqual({
            statusCode: 200,
            headers: { 'content-type': 'application/json', test: 'test' },
            body: { test: 'test' },
          });
        }
      );
    });
  });