Import Polymer classes instead of global ones in CommentApiMock

Change-Id: I01d619c73a6a15e6e789f41df55d7dfd7b292d77
This commit is contained in:
Dmitrii Filippov
2020-04-23 13:22:15 +02:00
parent 736175de0a
commit ba8fa47dbb

View File

@@ -14,41 +14,42 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function() {
'use strict';
class CommentApiMock extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
static get is() { return 'comment-api-mock'; }
import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin.js';
static get properties() {
return {
_changeComments: Object,
};
}
class CommentApiMock extends GestureEventListeners(
LegacyElementMixin(
PolymerElement)) {
static get is() { return 'comment-api-mock'; }
loadComments() {
return this._reloadComments();
}
/**
* For the purposes of the mock, _reloadDrafts is not included because its
* response is the same type as reloadComments, just makes less API
* requests. Since this is for test purposes/mocked data anyway, keep this
* file simpler by just using _reloadComments here instead.
*/
_reloadDraftsWithCallback(e) {
return this._reloadComments().then(() => e.detail.resolve());
}
_reloadComments() {
return this.$.commentAPI.loadAll(this._changeNum)
.then(comments => {
this._changeComments = this.$.commentAPI._changeComments;
});
}
static get properties() {
return {
_changeComments: Object,
};
}
customElements.define(CommentApiMock.is, CommentApiMock);
})();
loadComments() {
return this._reloadComments();
}
/**
* For the purposes of the mock, _reloadDrafts is not included because its
* response is the same type as reloadComments, just makes less API
* requests. Since this is for test purposes/mocked data anyway, keep this
* file simpler by just using _reloadComments here instead.
*/
_reloadDraftsWithCallback(e) {
return this._reloadComments().then(() => e.detail.resolve());
}
_reloadComments() {
return this.$.commentAPI.loadAll(this._changeNum)
.then(comments => {
this._changeComments = this.$.commentAPI._changeComments;
});
}
}
customElements.define(CommentApiMock.is, CommentApiMock);