Use page-error in gr-repo-detail-list and gr-plugin-list
Change-Id: I05de8ce29707e8e0d179c82afadd30fe15637f0f
This commit is contained in:
parent
d71d1957f0
commit
9e61778427
@ -81,7 +81,10 @@
|
||||
},
|
||||
|
||||
_getPlugins(filter, pluginsPerPage, offset) {
|
||||
return this.$.restAPI.getPlugins(filter, pluginsPerPage, offset)
|
||||
const errFn = response => {
|
||||
this.fire('page-error', {response});
|
||||
};
|
||||
return this.$.restAPI.getPlugins(filter, pluginsPerPage, offset, errFn)
|
||||
.then(plugins => {
|
||||
if (!plugins) {
|
||||
this._plugins = [];
|
||||
|
@ -131,8 +131,12 @@ limitations under the License.
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(value).then(() => {
|
||||
assert.isTrue(element.$.restAPI.getPlugins.lastCall
|
||||
.calledWithExactly('test', 25, 25));
|
||||
assert.equal(element.$.restAPI.getPlugins.lastCall.args[0],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getPlugins.lastCall.args[1],
|
||||
25);
|
||||
assert.equal(element.$.restAPI.getPlugins.lastCall.args[2],
|
||||
25);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -152,5 +156,26 @@ limitations under the License.
|
||||
assert.equal(getComputedStyle(element.$.loading).display, 'none');
|
||||
});
|
||||
});
|
||||
|
||||
suite('404', () => {
|
||||
test('fires page-error', done => {
|
||||
const response = {status: 404};
|
||||
sandbox.stub(element.$.restAPI, 'getPlugins',
|
||||
(filter, pluginsPerPage, opt_offset, errFn) => {
|
||||
errFn(response);
|
||||
});
|
||||
|
||||
element.addEventListener('page-error', e => {
|
||||
assert.deepEqual(e.detail.response, response);
|
||||
done();
|
||||
});
|
||||
|
||||
const value = {
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(value);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -118,16 +118,19 @@
|
||||
this._loading = true;
|
||||
this._items = [];
|
||||
Polymer.dom.flush();
|
||||
const errFn = response => {
|
||||
this.fire('page-error', {response});
|
||||
};
|
||||
if (detailType === DETAIL_TYPES.BRANCHES) {
|
||||
return this.$.restAPI.getRepoBranches(
|
||||
filter, repo, itemsPerPage, offset) .then(items => {
|
||||
filter, repo, itemsPerPage, offset, errFn).then(items => {
|
||||
if (!items) { return; }
|
||||
this._items = items;
|
||||
this._loading = false;
|
||||
});
|
||||
} else if (detailType === DETAIL_TYPES.TAGS) {
|
||||
return this.$.restAPI.getRepoTags(
|
||||
filter, repo, itemsPerPage, offset) .then(items => {
|
||||
filter, repo, itemsPerPage, offset, errFn).then(items => {
|
||||
if (!items) { return; }
|
||||
this._items = items;
|
||||
this._loading = false;
|
||||
|
@ -305,12 +305,41 @@ limitations under the License.
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params).then(() => {
|
||||
assert.isTrue(element.$.restAPI.getRepoBranches.lastCall
|
||||
.calledWithExactly('test', 'test', 25, 25));
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[0],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[1],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[2],
|
||||
25);
|
||||
assert.equal(element.$.restAPI.getRepoBranches.lastCall.args[3],
|
||||
25);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('404', () => {
|
||||
test('fires page-error', done => {
|
||||
const response = {status: 404};
|
||||
sandbox.stub(element.$.restAPI, 'getRepoBranches',
|
||||
(filter, repo, reposBranchesPerPage, opt_offset, errFn) => {
|
||||
errFn(response);
|
||||
});
|
||||
|
||||
element.addEventListener('page-error', e => {
|
||||
assert.deepEqual(e.detail.response, response);
|
||||
done();
|
||||
});
|
||||
|
||||
const params = {
|
||||
detail: 'branches',
|
||||
repo: 'test',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('Tags', () => {
|
||||
@ -459,8 +488,14 @@ limitations under the License.
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params).then(() => {
|
||||
assert.isTrue(element.$.restAPI.getRepoTags.lastCall
|
||||
.calledWithExactly('test', 'test', 25, 25));
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[0],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[1],
|
||||
'test');
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[2],
|
||||
25);
|
||||
assert.equal(element.$.restAPI.getRepoTags.lastCall.args[3],
|
||||
25);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -491,5 +526,28 @@ limitations under the License.
|
||||
assert.isTrue(element._handleCloseCreate.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('404', () => {
|
||||
test('fires page-error', done => {
|
||||
const response = {status: 404};
|
||||
sandbox.stub(element.$.restAPI, 'getRepoTags',
|
||||
(filter, repo, reposTagsPerPage, opt_offset, errFn) => {
|
||||
errFn(response);
|
||||
});
|
||||
|
||||
element.addEventListener('page-error', e => {
|
||||
assert.deepEqual(e.detail.response, response);
|
||||
done();
|
||||
});
|
||||
|
||||
const params = {
|
||||
repo: 'test',
|
||||
detail: 'tags',
|
||||
filter: 'test',
|
||||
offset: 25,
|
||||
};
|
||||
element._paramsChanged(params);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user