Convert base-url-behavior test to karma test
Change-Id: Ic30da5fc58c6cd04bc89a62addc487d98605458e
diff --git a/polygerrit-ui/app/.eslintrc.js b/polygerrit-ui/app/.eslintrc.js
index e7506e0..457db7a 100644
--- a/polygerrit-ui/app/.eslintrc.js
+++ b/polygerrit-ui/app/.eslintrc.js
@@ -206,6 +206,7 @@
"stub": "readonly",
"suite": "readonly",
"suiteSetup": "readonly",
+ "suiteTeardown": "readonly",
"teardown": "readonly",
"test": "readonly",
"fixtureFromElement": "readonly",
diff --git a/polygerrit-ui/app/behaviors/base-url-behavior/base-url-behavior_test.js b/polygerrit-ui/app/behaviors/base-url-behavior/base-url-behavior_test.js
index 61d7bac..44173323 100644
--- a/polygerrit-ui/app/behaviors/base-url-behavior/base-url-behavior_test.js
+++ b/polygerrit-ui/app/behaviors/base-url-behavior/base-url-behavior_test.js
@@ -1,58 +1,33 @@
-<!DOCTYPE html>
-<!--
-@license
-Copyright (C) 2017 The Android Open Source Project
+/**
+ * @license
+ * 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.
+ */
-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">
-<meta charset="utf-8">
-<title>base-url-behavior</title>
-
-<script src="/node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
-
-<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
-<script src="/components/wct-browser-legacy/browser.js"></script>
-<script type="module">
-import '../../test/common-test-setup.js';
-/** @type {string} */
-window.CANONICAL_PATH = '/r';
-</script>
-<test-fixture id="basic">
- <template>
- <test-element></test-element>
- </template>
-</test-fixture>
-
-<test-fixture id="within-overlay">
- <template>
- <gr-overlay>
- <test-element></test-element>
- </gr-overlay>
- </template>
-</test-fixture>
-
-<script type="module">
-import '../../test/common-test-setup.js';
+import '../../test/common-test-setup-karma.js';
import {Polymer} from '@polymer/polymer/lib/legacy/polymer-fn.js';
import {BaseUrlBehavior} from './base-url-behavior.js';
+
+const basicFixture = fixtureFromElement('test-element');
+
suite('base-url-behavior tests', () => {
let element;
- // eslint-disable-next-line no-unused-vars
- let overlay;
+ let originialCanonicalPath;
suiteSetup(() => {
+ originialCanonicalPath = window.CANONICAL_PATH;
+ window.CANONICAL_PATH = '/r';
// Define a Polymer element that uses this behavior.
Polymer({
is: 'test-element',
@@ -62,13 +37,15 @@
});
});
+ suiteTeardown(() => {
+ window.CANONICAL_PATH = originialCanonicalPath;
+ });
+
setup(() => {
- element = fixture('basic');
- overlay = fixture('within-overlay');
+ element = basicFixture.instantiate();
});
test('getBaseUrl', () => {
assert.deepEqual(element.getBaseUrl(), '/r');
});
});
-</script>
diff --git a/polygerrit-ui/app/test/tests.js b/polygerrit-ui/app/test/tests.js
index 2d795ec..6c7b43d 100644
--- a/polygerrit-ui/app/test/tests.js
+++ b/polygerrit-ui/app/test/tests.js
@@ -215,7 +215,6 @@
// Behaviors tests.
/* eslint-disable max-len */
const behaviors = [
- 'base-url-behavior/base-url-behavior_test.html',
'docs-url-behavior/docs-url-behavior_test.html',
'dom-util-behavior/dom-util-behavior_test.html',
'keyboard-shortcut-behavior/keyboard-shortcut-behavior_test.html',