| Index: appengine/config_service/ui/bower_components/test-fixture/test/test-fixture.html
|
| diff --git a/appengine/config_service/ui/bower_components/test-fixture/test/test-fixture.html b/appengine/config_service/ui/bower_components/test-fixture/test/test-fixture.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..90c34dc7c73691df251015e29e5e365964387862
|
| --- /dev/null
|
| +++ b/appengine/config_service/ui/bower_components/test-fixture/test/test-fixture.html
|
| @@ -0,0 +1,271 @@
|
| +<!doctype html>
|
| +<!--
|
| +@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
|
| +-->
|
| +<html>
|
| +<head>
|
| + <title>test-fixture</title>
|
| +
|
| + <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
| + <script src="../../web-component-tester/browser.js"></script>
|
| +
|
| + <link rel="import" id="test-fixture-import" href="../test-fixture.html">
|
| + <script src="../test-fixture-mocha.js"></script>
|
| +
|
| + <script>
|
| + (function() {
|
| + function XCustom() {
|
| + if (window.Reflect) {
|
| + return Reflect.construct(HTMLElement, [], XCustom);
|
| + }
|
| + return HTMLElement.call(this) || this;
|
| + }
|
| +
|
| + XCustom.prototype = Object.create(HTMLElement.prototype);
|
| + Object.defineProperty(XCustom.prototype, 'constructor', {
|
| + configurable: true,
|
| + enumerable: true,
|
| + writable: true,
|
| + value: XCustom,
|
| + });
|
| + XCustom.prototype.onDetached = function() {};
|
| + XCustom.prototype.disconnectedCallback =
|
| + XCustom.prototype.detachedCallback = function() {
|
| + this.onDetached();
|
| + };
|
| +
|
| + if (window.customElements) {
|
| + customElements.define('x-custom', XCustom);
|
| + } else if (document.registerElement) {
|
| + document.registerElement('x-custom', {
|
| + prototype: XCustom.prototype
|
| + });
|
| + } else {
|
| + throw new Error('No custom elements API was found.');
|
| + }
|
| + })();
|
| + </script>
|
| +</head>
|
| +<body>
|
| + <test-fixture id="TrivialFixture">
|
| + <template>
|
| + <div id="Foo"></div>
|
| + </template>
|
| + </test-fixture>
|
| + <test-fixture id="ComplexDomFixture">
|
| + <template>
|
| + <div id="Bar">
|
| + <div id="BarChild"></div>
|
| + </div>
|
| + <div id="BarSibling"></div>
|
| + </template>
|
| + </test-fixture>
|
| + <test-fixture id="MultiTemplateFixture">
|
| + <template>
|
| + <div id="Baz"></div>
|
| + </template>
|
| + <template>
|
| + <div id="Qux"></div>
|
| + <div id="QuxSibling"></div>
|
| + </template>
|
| + </test-fixture>
|
| + <test-fixture id="CommentedSingleChildFixture">
|
| + <template>
|
| + <!-- comment -->
|
| + <!-- comment -->
|
| + <div id="Foo"></div>
|
| + <!-- comment -->
|
| + </template>
|
| + </test-fixture>
|
| + <test-fixture id="CommentedMultiChildFixture">
|
| + <template>
|
| + <!-- comment -->
|
| + <div id="Bar">
|
| + <div id="BarChild"></div>
|
| + </div>
|
| + <!-- comment -->
|
| + <!-- comment -->
|
| + <div id="BarSibling"></div>
|
| + <!-- comment -->
|
| + <div id="Baz"></div>
|
| + </template>
|
| + </test-fixture>
|
| + <test-fixture id="AttachedFixture">
|
| + <template>
|
| + <x-custom></x-custom>
|
| + </template>
|
| + </test-fixture>
|
| + <script>
|
| +describe('test-fixture import', function() {
|
| + it('loads from test-fixture import', function() {
|
| + var importNode = document.getElementById('test-fixture-import');
|
| + expect(importNode.import).to.not.be.null;
|
| + });
|
| +});
|
| +describe('<test-fixture>', function () {
|
| + var trivialFixture;
|
| + var complexDomFixture;
|
| + var multiTemplateFixture;
|
| + var commentedSingleChildFixture;
|
| + var commentedMultiChildFixture;
|
| +
|
| + beforeEach(function () {
|
| + trivialFixture = document.getElementById('TrivialFixture');
|
| + complexDomFixture = document.getElementById('ComplexDomFixture');
|
| + multiTemplateFixture = document.getElementById('MultiTemplateFixture');
|
| + commentedSingleChildFixture = document.getElementById('CommentedSingleChildFixture');
|
| + commentedMultiChildFixture = document.getElementById('CommentedMultiChildFixture');
|
| + });
|
| +
|
| + afterEach(function () {
|
| + trivialFixture.restore();
|
| + complexDomFixture.restore();
|
| + multiTemplateFixture.restore();
|
| + commentedSingleChildFixture.restore();
|
| + commentedMultiChildFixture.restore();
|
| + });
|
| +
|
| + describe('an stamped-out fixture', function () {
|
| + var attachedFixture;
|
| + var element;
|
| +
|
| + beforeEach(function () {
|
| + attachedFixture = document.getElementById('AttachedFixture');
|
| + element = attachedFixture.create();
|
| + });
|
| +
|
| + afterEach(function () {
|
| + attachedFixture.restore();
|
| + });
|
| +
|
| + it('detaches the fixtured DOM when it is restored', function () {
|
| + var detached = false;
|
| +
|
| + element.onDetached = function () {
|
| + detached = true;
|
| + };
|
| +
|
| + attachedFixture.restore();
|
| + expect(detached).to.be.eql(true);
|
| + });
|
| + });
|
| +
|
| + describe('when create is called', function () {
|
| + var el;
|
| +
|
| + beforeEach(function () {
|
| + el = trivialFixture.create();
|
| + });
|
| +
|
| + it('clones all template fragments within itself', function () {
|
| + expect(el).to.be.ok;
|
| + expect(document.getElementById('Foo')).to.be.ok;
|
| + });
|
| +
|
| + it('detaches all fixture templates from itself', function () {
|
| + expect(trivialFixture.querySelectorAll('template').length).to.be.equal(0);
|
| + });
|
| +
|
| + describe('and then restore is called', function () {
|
| + beforeEach(function () {
|
| + trivialFixture.restore();
|
| + });
|
| +
|
| + it('re-attaches all fixture templates', function () {
|
| + expect(trivialFixture.querySelectorAll('template').length).to.be.equal(1);
|
| + });
|
| +
|
| + it('removes all cloned elements from itself', function () {
|
| + expect(document.getElementById('Foo')).to.not.be.ok;
|
| + });
|
| + });
|
| +
|
| + describe('for a dom with a single root element', function () {
|
| + it('returns a reference to the root element', function () {
|
| + expect(el).to.be.instanceOf(HTMLElement);
|
| + });
|
| + });
|
| +
|
| + describe('for a complex dom', function () {
|
| + var els;
|
| +
|
| + beforeEach(function () {
|
| + els = complexDomFixture.create();
|
| + });
|
| +
|
| + it('fixtures all the dom elements in the template', function () {
|
| + expect(document.getElementById('Bar')).to.be.ok;
|
| + expect(document.getElementById('BarSibling')).to.be.ok;
|
| + expect(document.getElementById('BarChild')).to.be.ok;
|
| + });
|
| +
|
| + it('returns an array of root elements', function () {
|
| + expect(els).to.be.instanceOf(Array);
|
| + expect(els[0]).to.be.instanceOf(HTMLElement);
|
| + expect(els[1]).to.be.instanceOf(HTMLElement);
|
| + });
|
| + });
|
| +
|
| + describe('when there are multiple templates', function () {
|
| + var groups;
|
| +
|
| + beforeEach(function () {
|
| + groups = multiTemplateFixture.create();
|
| + });
|
| +
|
| + it('fixtures elements from all of the templates', function () {
|
| + expect(document.getElementById('Baz')).to.be.ok;
|
| + expect(document.getElementById('Qux')).to.be.ok;
|
| + });
|
| +
|
| + it('returns an array with elements grouped by template', function () {
|
| + expect(groups).to.be.instanceOf(Array);
|
| + expect(groups[0]).to.be.instanceOf(HTMLElement);
|
| + expect(groups[1]).to.be.instanceOf(Array);
|
| + expect(groups[1][0]).to.be.instanceOf(HTMLElement);
|
| + expect(groups[1][1]).to.be.instanceOf(HTMLElement);
|
| + });
|
| + });
|
| +
|
| + describe('when there are comments in the template', function() {
|
| + var el;
|
| + var els;
|
| +
|
| + beforeEach(function () {
|
| + el = commentedSingleChildFixture.create();
|
| + els = commentedMultiChildFixture.create();
|
| + });
|
| +
|
| + it('returns a single element if the template has a single child', function() {
|
| + expect(el).to.be.instanceOf(HTMLElement);
|
| + });
|
| +
|
| + it('returns multiple elements if the template has multiple children', function() {
|
| + expect(els).to.be.instanceOf(Array);
|
| + expect(els.length).to.equal(3);
|
| + });
|
| + });
|
| + });
|
| +
|
| + describe('when the fixture global is called', function () {
|
| + var el;
|
| +
|
| + beforeEach(function () {
|
| + el = fixture('TrivialFixture');
|
| + });
|
| +
|
| + it('generates a DOM fragment from the associated fixture', function () {
|
| + expect(el).to.be.equal(document.getElementById('Foo'));
|
| + });
|
| + });
|
| +});
|
| + </script>
|
| +
|
| +</body>
|
| +</html>
|
|
|