| Index: appengine/swarming/ui/test/common/test-pageable-data.html
|
| diff --git a/appengine/swarming/ui/test/common/test-pageable-data.html b/appengine/swarming/ui/test/common/test-pageable-data.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..808684a306e6bd710f807db23237f0c5180b5df2
|
| --- /dev/null
|
| +++ b/appengine/swarming/ui/test/common/test-pageable-data.html
|
| @@ -0,0 +1,110 @@
|
| +<!--
|
| + Copyright 2016 The LUCI Authors. All rights reserved.
|
| + Use of this source code is governed under the Apache License, Version 2.0
|
| + that can be found in the LICENSE file.
|
| +
|
| +-->
|
| +<!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">
|
| +
|
| + <script src="../../web-component-tester/browser.js"></script>
|
| +
|
| + <link rel="import" href="/res/imp/common/pageable-data-demo.html">
|
| + </head>
|
| + <body>
|
| +
|
| + <test-fixture id="pageable-data-fixture">
|
| + <template>
|
| + <pageable-data-demo>
|
| + </pageable-data-demo>
|
| + </template>
|
| + </test-fixture>
|
| +
|
| + <script>
|
| + suite("<pageable-data>", function() {
|
| +
|
| + var demo;
|
| + var pd;
|
| +
|
| + setup(function() {
|
| + server.respondImmediately = true;
|
| + demo = fixture("pageable-data-fixture");
|
| + pd = demo.$.pd;
|
| + });
|
| +
|
| + test("Has a default label set", function(done) {
|
| + assert.equal(pd.label, "Show More");
|
| + // Because we use Promises to do the xhr request, and Promises are
|
| + // handled asynchronously, we must always wait for the loading to
|
| + // be finished.
|
| + pd.addEventListener("_finishedLoading", function(){
|
| + done();
|
| + });
|
| + });
|
| +
|
| + test("Has a button that reflects the label", function(done) {
|
| + var button = Polymer.dom(pd.root).querySelector("button");
|
| + assert.isOk(button);
|
| + assert.equal(button.textContent.trim(), "Show More");
|
| + assert.isNotOk(button.disabled, "Button should be disabled by default");
|
| + pd.label = "I am a button";
|
| + assert.equal(button.textContent.trim(), "I am a button");
|
| + assert.isNotOk(button.disabled, "Button should be disabled by default");
|
| + pd.addEventListener("_finishedLoading", function(){
|
| + done();
|
| + });
|
| + });
|
| +
|
| + test("Loads 10 items by default", function(done) {
|
| + pd.addEventListener("_finishedLoading", function(){
|
| + assert.isNotOk(pd.busy);
|
| + assert.isOk(pd.output);
|
| + assert.equal(10, pd.output.length);
|
| + done();
|
| + });
|
| + });
|
| +
|
| + test("Loads 10 more items on a click", function(done) {
|
| + var button = Polymer.dom(pd.root).querySelector("button");
|
| +
|
| + var times = 0;
|
| + pd.addEventListener("_finishedLoading", function(){
|
| + times++;
|
| + if (times == 2) {
|
| + assert.isNotOk(pd.busy);
|
| + assert.isOk(pd.output);
|
| + assert.equal(20, pd.output.length);
|
| + done();
|
| + return;
|
| + }
|
| + button.click();
|
| + });
|
| + });
|
| +
|
| + test("When there are no more items, the button is disabled", function(done) {
|
| + var button = Polymer.dom(pd.root).querySelector("button");
|
| +
|
| + var times = 0;
|
| + pd.addEventListener("_finishedLoading", function(){
|
| + times++;
|
| + if (times == 3) {
|
| + assert.isNotOk(pd.busy);
|
| + assert.isOk(pd.output);
|
| + assert.equal(27, pd.output.length);
|
| + assert.isOk(button.disabled);
|
| + done();
|
| + return;
|
| + }
|
| + button.click();
|
| + });
|
| + });
|
| +
|
| + });
|
| + </script>
|
| +
|
| + </body>
|
| +</html>
|
|
|