Sha256: 4320098bf48bb323a45bc86975d099976163a73fdc6e5ee805eb4f652adcdde4

Contents?: true

Size: 1.17 KB

Versions: 46

Compression:

Stored size: 1.17 KB

Contents

import {
    expect
} from 'chai';
import configSamples from './streamConfigSamples';
import validateConfig from '../dist/validateStreamConfig';
import configSchema from '../src/schemas/streamConfig.json';
import Ajv from 'ajv';
import ajvKeywords from 'ajv-keywords';

describe('streamConfig.json schema', () => {
  var validate;

  before(() => {
    var ajv = new Ajv({allErrors: true});
    ajvKeywords(ajv, 'typeof');
    validate = ajv.compile(configSchema);
  });

  it('should pass validation of valid streamConfig samples', () => {
    configSamples.valid.forEach((sample, i) => {
      testValid(sample, validate);
      testValid(sample, validateConfig);
    });

    function testValid(sample, validate) {
      var valid = validate(sample);
      if (!valid) console.log(validate.errors);
      expect(valid).to.equal(true);
    }
  });

  it('should fail validation of invalid streamConfig samples', () => {
    configSamples.invalid.forEach((sample, i) => {
      testInvalid(sample, validate);
      testInvalid(sample, validateConfig);
    });

    function testInvalid(sample, validate) {
      var valid = validate(sample);
      expect(valid).to.equal(false);
    }
  });
});

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.21.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.20.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.19.1 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.19.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.18.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.17.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.16.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.15.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.14.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.13.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.12.2 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.12.1 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.12.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.11.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.10.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.9.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.8.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.7.0 node_modules/table/test/streamConfig.js
govuk_publishing_components-17.6.1 node_modules/table/test/streamConfig.js