iron-doc-viewer.html 3.66 KB
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
    <title>Tests</title>

    <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
    <script src="../../web-component-tester/browser.js"></script>
    <script src="../../test-fixture/test-fixture-mocha.js"></script>

    <link rel="import" href="../../polymer/polymer.html">
    <link rel="import" href="../../test-fixture/test-fixture.html">

    <link rel="import" href="../iron-doc-viewer.html">
  </head>
  <body>

    <iron-doc-viewer>
      {
        "is": "awesome-sauce",
        "properties": [
          {"name": "isAwesome", "type": "boolean", "desc": "Is it awesome?"}
        ]
      }
    </iron-doc-viewer>

    <test-fixture id="bound">
      <template is="dom-template">
        <iron-doc-viewer descriptor="{{descriptor}}" bound></iron-doc-viewer>
      </template>
    </test-fixture>

    <test-fixture id="json">
      <template is="dom-template">
        <iron-doc-viewer json>
          {
            "is": "awesome-sauce",
            "properties": [
              {"name": "isAwesome", "type": "boolean", "desc": "Is it awesome?"}
            ]
          }
        </iron-doc-viewer>
      </template>
    </test-fixture>

    <test-fixture id="json-and-bound">
      <template is="dom-template">
        <iron-doc-viewer descriptor="{{descriptor}}" jsonbound>
          {
            "is": "awesome-sauce",
            "properties": [
              {"name": "isAwesome", "type": "boolean", "desc": "Is it awesome?"}
            ]
          }
        </iron-doc-viewer>
      </template>
    </test-fixture>

    <script>

      var ELEMENT = {
        "is": "awesome-sauce",
        "properties": [
          {"name": "isAwesome", "type": "boolean", "desc": "Is it awesome?"},
        ]
      };

      describe('<iron-doc-viewer>', function() {

        var page;
        afterEach(function() {
          page = null; // Make sure that we don't reuse another test's element.
        });

        describe('with a bound descriptor', function() {

          beforeEach(function() { page = fixture('bound', {descriptor: ELEMENT}); });

          it('loads the descriptor', function() {
            expect(page.descriptor.is).to.eq('awesome-sauce');
            expect(page.descriptor.properties.length).to.eq(1);
          });

        });

        describe('with a JSON descriptor', function() {

          beforeEach(function() { page = fixture('json'); });

          it('loads the descriptor', function() {
            expect(page.descriptor.is).to.eq('awesome-sauce');
            expect(page.descriptor.properties.length).to.eq(1);
          });

        });

        describe('edge cases', function() {

        //   // TODO(nevir): Cannot enable until https://github.com/Polymer/polymer/issues/1200
        //   it.skip('throws when a bound and JSON descriptor are provided', function() {
        //     expect(function() {
        //       fixture('json-and-bound', {descriptor: ELEMENT});
        //     }).to.throw(Error, /descriptor/i);
        //   });

        });

      });

    </script>

  </body>
</html>