Files
gerrit/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list_test.html
Paladox none 9b173094e4 PolyGerrit: Use gr-list-view on gr-plugin-list
Since https://gerrit-review.googlesource.com/#/c/gerrit/+/116330/
it's now possible to use filters and pagination.

Change-Id: I19c9fed9acbece95fe78e0b8fc9983a8a819c2b7
2017-07-31 17:55:48 +00:00

141 lines
4.0 KiB
HTML

<!DOCTYPE html>
<!--
Copyright (C) 2017 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>gr-plugin-list</title>
<script src="../../../bower_components/page/page.js"></script>
<script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<script src="../../../bower_components/web-component-tester/browser.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<link rel="import" href="gr-plugin-list.html">
<script>void(0);</script>
<test-fixture id="basic">
<template>
<gr-plugin-list></gr-plugin-list>
</template>
</test-fixture>
<script>
let counter;
const pluginGenerator = () => {
return {
id: `test${++counter}`,
index_url: `plugins/test${counter}/`,
version: '3.0-SNAPSHOT',
disabled: false,
};
};
suite('gr-plugin-list tests', () => {
let element;
let plugins;
let sandbox;
let value;
setup(() => {
sandbox = sinon.sandbox.create();
element = fixture('basic');
counter = 0;
});
teardown(() => {
sandbox.restore();
});
suite('list with plugins', () => {
setup(done => {
plugins = _.times(26, pluginGenerator);
stub('gr-rest-api-interface', {
getPlugins(num, offset) {
return Promise.resolve(plugins);
},
});
element._paramsChanged(value).then(() => { flush(done); });
});
test('plugin in the list is formatted correctly', done => {
flush(() => {
assert.equal(element._plugins[2].id, 'test3');
assert.equal(element._plugins[2].index_url, 'plugins/test3/');
assert.equal(element._plugins[2].version, '3.0-SNAPSHOT');
assert.equal(element._plugins[2].disabled, false);
done();
});
});
test('_shownPlugins', () => {
assert.equal(element._shownPlugins.length, 25);
});
});
suite('list with less then 26 plugins', () => {
setup(done => {
plugins = _.times(25, pluginGenerator);
stub('gr-rest-api-interface', {
getPlugins(num, offset) {
return Promise.resolve(plugins);
},
});
element._paramsChanged(value).then(() => { flush(done); });
});
test('_shownPlugins', () => {
assert.equal(element._shownPlugins.length, 25);
});
});
suite('filter', () => {
test('_paramsChanged', done => {
sandbox.stub(element.$.restAPI, 'getPlugins', () => {
return Promise.resolve(plugins);
});
const value = {
filter: 'test',
offset: 25,
};
element._paramsChanged(value).then(() => {
assert.isTrue(element.$.restAPI.getPlugins.lastCall
.calledWithExactly('test', 25, 25));
done();
});
});
});
suite('loading', () => {
test('correct contents are displayed', () => {
assert.isTrue(element._loading);
assert.equal(element.computeLoadingClass(element._loading), 'loading');
assert.equal(getComputedStyle(element.$.loading).display, 'block');
element._loading = false;
element._plugins = _.times(25, pluginGenerator);
flushAsynchronousOperations();
assert.equal(element.computeLoadingClass(element._loading), '');
assert.equal(getComputedStyle(element.$.loading).display, 'none');
});
});
});
</script>