summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Borden <frankborden@google.com>2022-09-27 18:12:17 +0200
committerFrank Borden <frankborden@google.com>2022-09-27 18:28:14 +0200
commit03ba5086b9acaa91bd7c756abb4fb851d9bfda78 (patch)
tree9d7f27af73027d18468aea541f7d904bc7ad4368
parent0a9c74f6deb7c991e438b26f173f8fccb0325dc6 (diff)
Convert gr-change-reply-js-api_test to Typescript
Compare to PS1 for code changes. Release-Notes: skip Change-Id: I8141eb42fafcccec7336e42841ed7e62de587195
-rw-r--r--polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.js87
-rw-r--r--polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.ts74
2 files changed, 74 insertions, 87 deletions
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.js
deleted file mode 100644
index f19996bac2..0000000000
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * @license
- * Copyright 2016 Google LLC
- * SPDX-License-Identifier: Apache-2.0
- */
-import '../../../test/common-test-setup';
-import '../../change/gr-reply-dialog/gr-reply-dialog';
-import {stubRestApi} from '../../../test/test-utils';
-// eslint-disable-next-line import/named
-import {fixture, html, assert} from '@open-wc/testing';
-
-suite('gr-change-reply-js-api tests', () => {
- let element;
- let changeReply;
- let plugin;
-
- setup(() => {
- stubRestApi('getAccount').returns(Promise.resolve(null));
- });
-
- suite('early init', () => {
- setup(async () => {
- window.Gerrit.install(
- p => {
- plugin = p;
- },
- '0.1',
- 'http://test.com/plugins/testplugin/static/test.js'
- );
- changeReply = plugin.changeReply();
- element = await fixture(html`<gr-reply-dialog></gr-reply-dialog>`);
- });
-
- teardown(() => {
- changeReply = null;
- });
-
- test('works', () => {
- sinon.stub(element, 'getLabelValue').returns('+123');
- assert.equal(changeReply.getLabelValue('My-Label'), '+123');
-
- sinon.stub(element, 'setLabelValue');
- changeReply.setLabelValue('My-Label', '+1337');
- assert.isTrue(
- element.setLabelValue.calledWithExactly('My-Label', '+1337')
- );
-
- sinon.stub(element, 'setPluginMessage');
- changeReply.showMessage('foobar');
- assert.isTrue(element.setPluginMessage.calledWithExactly('foobar'));
- });
- });
-
- suite('normal init', () => {
- setup(async () => {
- element = await fixture(html`<gr-reply-dialog></gr-reply-dialog>`);
- window.Gerrit.install(
- p => {
- plugin = p;
- },
- '0.1',
- 'http://test.com/plugins/testplugin/static/test.js'
- );
- changeReply = plugin.changeReply();
- });
-
- teardown(() => {
- changeReply = null;
- });
-
- test('works', () => {
- sinon.stub(element, 'getLabelValue').returns('+123');
- assert.equal(changeReply.getLabelValue('My-Label'), '+123');
-
- sinon.stub(element, 'setLabelValue');
- changeReply.setLabelValue('My-Label', '+1337');
- assert.isTrue(
- element.setLabelValue.calledWithExactly('My-Label', '+1337')
- );
-
- sinon.stub(element, 'setPluginMessage');
- changeReply.showMessage('foobar');
- assert.isTrue(element.setPluginMessage.calledWithExactly('foobar'));
- });
- });
-});
-
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.ts
new file mode 100644
index 0000000000..1d47d376d4
--- /dev/null
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-change-reply-js-api_test.ts
@@ -0,0 +1,74 @@
+/**
+ * @license
+ * Copyright 2016 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+import '../../../test/common-test-setup';
+import '../../change/gr-reply-dialog/gr-reply-dialog';
+import {stubElement} from '../../../test/test-utils';
+import {assert} from '@open-wc/testing';
+import {PluginApi} from '../../../api/plugin';
+import {ChangeReplyPluginApi} from '../../../api/change-reply';
+
+suite('gr-change-reply-js-api tests', () => {
+ let changeReply: ChangeReplyPluginApi;
+ let plugin: PluginApi;
+
+ suite('early init', () => {
+ setup(async () => {
+ window.Gerrit.install(
+ p => {
+ plugin = p;
+ },
+ '0.1',
+ 'http://test.com/plugins/testplugin/static/test.js'
+ );
+ changeReply = plugin.changeReply();
+ });
+
+ test('works', () => {
+ stubElement('gr-reply-dialog', 'getLabelValue').returns('+123');
+ assert.equal(changeReply.getLabelValue('My-Label'), '+123');
+
+ const setLabelValueStub = stubElement('gr-reply-dialog', 'setLabelValue');
+ changeReply.setLabelValue('My-Label', '+1337');
+ assert.isTrue(setLabelValueStub.calledWithExactly('My-Label', '+1337'));
+
+ const setPluginMessageStub = stubElement(
+ 'gr-reply-dialog',
+ 'setPluginMessage'
+ );
+ changeReply.showMessage('foobar');
+ assert.isTrue(setPluginMessageStub.calledWithExactly('foobar'));
+ });
+ });
+
+ suite('normal init', () => {
+ setup(async () => {
+ window.Gerrit.install(
+ p => {
+ plugin = p;
+ },
+ '0.1',
+ 'http://test.com/plugins/testplugin/static/test.js'
+ );
+ changeReply = plugin.changeReply();
+ });
+
+ test('works', () => {
+ stubElement('gr-reply-dialog', 'getLabelValue').returns('+123');
+ assert.equal(changeReply.getLabelValue('My-Label'), '+123');
+
+ const setLabelValueStub = stubElement('gr-reply-dialog', 'setLabelValue');
+ changeReply.setLabelValue('My-Label', '+1337');
+ assert.isTrue(setLabelValueStub.calledWithExactly('My-Label', '+1337'));
+
+ const setPluginMessageStub = stubElement(
+ 'gr-reply-dialog',
+ 'setPluginMessage'
+ );
+ changeReply.showMessage('foobar');
+ assert.isTrue(setPluginMessageStub.calledWithExactly('foobar'));
+ });
+ });
+});