JSPM

  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q100808F
  • License MIT

fast-check value generator for smartlyio/oats types

Package Exports

  • @smartlyio/oats-fast-check

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@smartlyio/oats-fast-check) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Fast-check generators for smartlyio/oats

Fast-check generators for @smartlyio/oats types.

generator.named

Generate values of named types from the openapi specification. Here using a jest wrapper.

// yarn jest examples/type.spec.ts
import * as fc from 'fast-check';
import { generator } from '../src/index';
import * as runtime from '@smartlyio/oats-runtime';
import * as types from '../tmp/openapi.types.generated';

describe('value generation', () => {
  it ('generates valid values', () =>
    fc.assert(
      fc.property(
        // create a fast-check Arbitrary from the type structure
        generator.named(types.typeTestObject),
        (value: types.TestObject) => {
          // assert that all the generated values are valid
          const json = runtime.valueClass.toJSON(value);
          types.typeTestObject.maker(json).success();
        }
      )
  ))
});