How to use the @stoplight/prism-core/src/__tests__/utils.assertRight 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 / mocker / negotiator / __tests__ / NegotiatorHelpers.spec.ts View on Github external
jest.spyOn(helpers, 'negotiateByPartialOptionsAndHttpContent').mockReturnValue(E.right(fakeOperationConfig));

        const actualOperationConfig = helpers.negotiateDefaultMediaType(partialOptions, response);

        expect(helpers.negotiateByPartialOptionsAndHttpContent).toHaveBeenCalledTimes(1);
        expect(helpers.negotiateByPartialOptionsAndHttpContent).toHaveBeenCalledWith(
          {
            code,
            dynamic: partialOptions.dynamic,
            exampleKey: partialOptions.exampleKey,
          },
          contents[1] // Check that the */* has been requested
        );

        assertRight(actualOperationConfig, operationConfig => {
          expect(operationConfig).toEqual(fakeOperationConfig);
        });
      });
    });
github stoplightio / prism / packages / http / src / mocker / __tests__ / HttpMocker.spec.ts View on Github external
it('prefers the first example', () =>
                assertRight(eitherResponseWithMultipleExamples, responseWithMultipleExamples =>
                  expect(responseWithMultipleExamples.body).toHaveProperty('middlename', 'WW')
                ));
            });
github stoplightio / prism / packages / http / src / utils / __tests__ / serializeBody.spec.ts View on Github external
it('passes through', () => {
      assertRight(
        serializeBody(undefined),
        result => expect(result).toBeUndefined(),
      );
    })
  });
github stoplightio / prism / packages / http / src / validator / validators / __tests__ / query.spec.ts View on Github external
it('validates positively against schema', () => {
                assertRight(
                  httpQueryValidator.validate({ param: 'abc' }, [
                    {
                      name: 'param',
                      style: HttpParamStyles.Form,
                      schema: { type: 'string' },
                    },
                  ])
                );

                expect(validateAgainstSchemaModule.validateAgainstSchema).toReturnWith(O.none);
              });
            });
github stoplightio / prism / packages / http / src / mocker / __tests__ / functional.spec.ts View on Github external
test('return lowest 2xx response and the first example matching the media type', () => {
          const response = mock({
            config: { dynamic: false },
            resource: httpOperations[1],
            input: Object.assign({}, httpRequests[0], {
              data: Object.assign({}, httpRequests[0].data, {
                headers: { accept: 'application/xml' },
              }),
            }),
          })(logger);

          assertRight(response, result => {
            expect(result.statusCode).toBe(200);
            expect(result.headers).toHaveProperty('x-todos-publish');
          });
        });
github stoplightio / prism / packages / http / src / mocker / __tests__ / HttpMocker.spec.ts View on Github external
it('should use such key', () => {
              assertRight(eitherResponse, response => expect(response.body).toHaveProperty('surname', 'Kent'));
            });
          });
github stoplightio / prism / packages / http / src / validator / __tests__ / functional.spec.ts View on Github external
it('does not return warnings', () => {
        assertRight(
          validateInput({
            resource,
            element: {
              method: 'get',
              url: {
                path: '/test',
                query: {},
              },
            },
          })
        );
      });
    });
github stoplightio / prism / packages / http / src / mocker / __tests__ / HttpMocker.spec.ts View on Github external
it('prefers the default', () =>
                assertRight(eitherResponseWithDefault, responseWithDefault =>
                  expect(responseWithDefault.body).toHaveProperty('middlename', 'JJ')
                ));
            });
github stoplightio / prism / packages / http / src / mocker / negotiator / __tests__ / NegotiatorHelpers.spec.ts View on Github external
it('and cannot find example and dynamic does not exist throw error', () => {
      const partialOptions = {
        dynamic: false,
        code: '200',
      };

      const httpContent: IMediaTypeContent = {
        mediaType: chance.string(),
        examples: [],
        encodings: [],
      };

      const proposedResponse = helpers.negotiateByPartialOptionsAndHttpContent(partialOptions, httpContent);

      assertRight(proposedResponse, response => {
        expect(response).toHaveProperty('code');
        expect(response).toHaveProperty('mediaType');
      });
    });
  });
github stoplightio / prism / packages / http / src / mocker / negotiator / __tests__ / NegotiatorHelpers.spec.ts View on Github external
it('should take the first content type', () => {
        assertRight(negotiationResult, result => {
          expect(result.mediaType).toBe('application/xml');
        });
      });
    });