<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base data-ice="baseUrl" href="../../../">
  <title data-ice="title">tests/util/schemaValidator.test.js | Plugged In API Document</title>
  <link type="text/css" rel="stylesheet" href="css/style.css">
  <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
  <script src="script/prettify/prettify.js"></script>
  
  
  <script src="script/manual.js"></script>
</head>
<body class="layout-container" data-ice="rootContainer">

<header>
  <a href="./">Home</a>
  
  <a href="identifiers.html">Reference</a>
  <a href="source.html">Source</a>
  <a href="test.html" data-ice="testLink">Test</a>
  <a data-ice="repoURL" href="https://github.com/rawphp/plugged-in" class="repo-url-github">Repository</a>
  <div class="search-box">
  <span>
    <img src="./image/search.png">
    <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
  </span>
    <ul class="search-result"></ul>
  </div>
</header>

<nav class="navigation" data-ice="nav"><div>
  <ul>
    
  <li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/Event.js~Event.html">Event</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/Npm.js~Npm.html">Npm</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/PluginManager.js~PluginManager.html">PluginManager</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">errors</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/errors/ValidationError.js~ValidationError.html">ValidationError</a></span></span></li>
</ul>
</div>
</nav>

<div class="content" data-ice="content"><h1 data-ice="title">tests/util/schemaValidator.test.js</h1>
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">import chai from &apos;chai&apos;;
import Ajv from &apos;ajv&apos;;
import validator from &apos;./../../src/util/schemaValidator&apos;;

const expect = chai.expect;

describe(&apos;schemaValidator&apos;, () =&gt; {
  const schema = &apos;http://plugged-in.x-c-o-d-e.com/schema/configuration+v1#&apos;;

  it(&apos;has Ajv instance as a property&apos;, () =&gt; {
    expect(validator.ajv instanceof Ajv).to.equal(true);
  });

  it(&apos;has all available schemas&apos;, () =&gt; {
    expect(Object.keys(validator.ajv._schemas).length).to.be.equal(2); // eslint-disable-line no-underscore-dangle, max-len
    expect(validator.ajv.getSchema(&apos;http://plugged-in.x-c-o-d-e.com/schema/configuration+v1#&apos;)).not.to.be.equal(undefined);
  });

  it(&apos;successfully validates correct schema&apos;, async () =&gt; {
    const object = {
      context: &apos;valid-context&apos;,
      provides: {
        init: &apos;onInit&apos;,
      },
    };

    await validator.validate(schema, object);
  });

  it(&apos;successfully validates invalid schema&apos;, async () =&gt; {
    try {
      const object = {
        context: &apos;valid-context&apos;,
      };

      await validator.validate(schema, object);
    } catch (error) {
      expect(error.message).to.equal(&apos;data should have required property \&apos;provides\&apos;&apos;);
    }
  });
});
</code></pre>

</div>

<footer class="footer">
  Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(0.4.8)</span></a>
</footer>

<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>
