Convert gr-attribute-helper_test to typescript

The helper only works on Polymer elements so cannot test with Lit.

Release-Notes: skip
Change-Id: Idf0c9b7c7b53c7ee9fca28502b2ce795eeb8eb2d
diff --git a/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.js b/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.js
deleted file mode 100644
index 43bbcd3..0000000
--- a/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * @license
- * Copyright 2017 Google LLC
- * SPDX-License-Identifier: Apache-2.0
- */
-import '../../../test/common-test-setup';
-import {Polymer} from '@polymer/polymer/lib/legacy/polymer-fn';
-// eslint-disable-next-line import/named
-import {fixture, html, assert} from '@open-wc/testing';
-
-Polymer({
-  is: 'gr-attribute-helper-some-element',
-  properties: {
-    fooBar: {
-      type: Object,
-      notify: true,
-    },
-  },
-});
-
-suite('gr-attribute-helper tests', () => {
-  let element;
-  let instance;
-
-  setup(async () => {
-    let plugin;
-    window.Gerrit.install(
-        p => {
-          plugin = p;
-        },
-        '0.1',
-        'http://test.com/plugins/testplugin/static/test.js'
-    );
-    element = await fixture(
-        html`
-        <gr-attribute-helper-some-element></gr-attribute-helper-some-element>
-      `
-    );
-    instance = plugin.attributeHelper(element);
-  });
-
-  test('resolved on value change from undefined', () => {
-    const promise = instance.get('fooBar').then(value => {
-      assert.equal(value, 'foo! bar!');
-    });
-    element.fooBar = 'foo! bar!';
-    return promise;
-  });
-
-  test('resolves to current attribute value', () => {
-    element.fooBar = 'foo-foo-bar';
-    const promise = instance.get('fooBar').then(value => {
-      assert.equal(value, 'foo-foo-bar');
-    });
-    element.fooBar = 'no bar';
-    return promise;
-  });
-
-  test('bind', () => {
-    const stub = sinon.stub();
-    element.fooBar = 'bar foo';
-    const unbind = instance.bind('fooBar', stub);
-    element.fooBar = 'partridge in a foo tree';
-    element.fooBar = 'five gold bars';
-    assert.equal(stub.callCount, 3);
-    assert.deepEqual(stub.args[0], ['bar foo']);
-    assert.deepEqual(stub.args[1], ['partridge in a foo tree']);
-    assert.deepEqual(stub.args[2], ['five gold bars']);
-    stub.reset();
-    unbind();
-    instance.fooBar = 'ladies dancing';
-    assert.isFalse(stub.called);
-  });
-});
-
diff --git a/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.ts b/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.ts
new file mode 100644
index 0000000..5c15816
--- /dev/null
+++ b/polygerrit-ui/app/elements/plugins/gr-attribute-helper/gr-attribute-helper_test.ts
@@ -0,0 +1,82 @@
+/**
+ * @license
+ * Copyright 2017 Google LLC
+ * SPDX-License-Identifier: Apache-2.0
+ */
+import '../../../test/common-test-setup';
+import {Polymer} from '@polymer/polymer/lib/legacy/polymer-fn';
+import {fixture, html, assert} from '@open-wc/testing';
+import {PluginApi} from '../../../api/plugin';
+import {AttributeHelperPluginApi} from '../../../api/attribute-helper';
+
+// Attribute helper only works on Polymer notify events, so we cannot use a Lit
+// element for the test.
+Polymer({
+  is: 'foo-bar',
+  properties: {
+    fooBar: {
+      type: Object,
+      notify: true,
+    },
+  },
+});
+
+declare global {
+  interface HTMLElementTagNameMap {
+    'foo-bar': HTMLElement;
+  }
+}
+
+suite('gr-attribute-helper tests', () => {
+  let element: HTMLElement & {fooBar?: string};
+  let instance: AttributeHelperPluginApi;
+
+  setup(async () => {
+    let plugin: PluginApi;
+    window.Gerrit.install(
+      p => {
+        plugin = p;
+      },
+      '0.1',
+      'http://test.com/plugins/testplugin/static/test.js'
+    );
+    element = await fixture(html`<foo-bar></foo-bar>`);
+    instance = plugin!.attributeHelper(element);
+  });
+
+  test('get resolves on value change from undefined', async () => {
+    const fooBarWatch = instance.get('fooBar');
+    element.fooBar = 'foo! bar!';
+    const value = await fooBarWatch;
+
+    assert.equal(value, 'foo! bar!');
+  });
+
+  test('get resolves to current attribute value', async () => {
+    element.fooBar = 'foo-foo-bar';
+    const fooBarWatch = instance.get('fooBar');
+    element.fooBar = 'no bar';
+    const value = await fooBarWatch;
+
+    assert.equal(value, 'foo-foo-bar');
+  });
+
+  test('bind', () => {
+    const stub = sinon.stub();
+    element.fooBar = 'bar foo';
+    const unbind = instance.bind('fooBar', stub);
+    element.fooBar = 'partridge in a foo tree';
+    element.fooBar = 'five gold bars';
+
+    assert.equal(stub.callCount, 3);
+    assert.deepEqual(stub.args[0], ['bar foo']);
+    assert.deepEqual(stub.args[1], ['partridge in a foo tree']);
+    assert.deepEqual(stub.args[2], ['five gold bars']);
+
+    stub.reset();
+    unbind();
+    element.fooBar = 'ladies dancing';
+
+    assert.isFalse(stub.called);
+  });
+});