| <!DOCTYPE html> |
| <!-- |
| @license |
| Copyright (C) 2018 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. |
| --> |
| <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"> |
| <title>gr-key-binding-display</title> |
| |
| <script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> |
| <script src="../../../bower_components/web-component-tester/browser.js"></script> |
| <link rel="import" href="../../../test/common-test-setup.html"/> |
| <link rel="import" href="gr-keyboard-shortcuts-dialog.html"> |
| |
| <script>void(0);</script> |
| |
| <test-fixture id="basic"> |
| <template> |
| <gr-keyboard-shortcuts-dialog></gr-keyboard-shortcuts-dialog> |
| </template> |
| </test-fixture> |
| |
| <script> |
| suite('gr-keyboard-shortcuts-dialog tests', () => { |
| const kb = window.Gerrit.KeyboardShortcutBinder; |
| let element; |
| |
| setup(() => { |
| element = fixture('basic'); |
| }); |
| |
| function update(directory) { |
| element._onDirectoryUpdated(directory); |
| flushAsynchronousOperations(); |
| } |
| |
| suite('_left and _right contents', () => { |
| test('empty dialog', () => { |
| assert.strictEqual(element._left.length, 0); |
| assert.strictEqual(element._right.length, 0); |
| }); |
| |
| test('everywhere goes on left', () => { |
| update(new Map([ |
| [kb.ShortcutSection.EVERYWHERE, ['everywhere shortcuts']], |
| ])); |
| assert.deepEqual( |
| element._left, |
| [ |
| { |
| section: kb.ShortcutSection.EVERYWHERE, |
| shortcuts: ['everywhere shortcuts'], |
| }, |
| ]); |
| assert.strictEqual(element._right.length, 0); |
| }); |
| |
| test('navigation goes on left', () => { |
| update(new Map([ |
| [kb.ShortcutSection.NAVIGATION, ['navigation shortcuts']], |
| ])); |
| assert.deepEqual( |
| element._left, |
| [ |
| { |
| section: kb.ShortcutSection.NAVIGATION, |
| shortcuts: ['navigation shortcuts'], |
| }, |
| ]); |
| assert.strictEqual(element._right.length, 0); |
| }); |
| |
| test('actions go on right', () => { |
| update(new Map([ |
| [kb.ShortcutSection.ACTIONS, ['actions shortcuts']], |
| ])); |
| assert.deepEqual( |
| element._right, |
| [ |
| { |
| section: kb.ShortcutSection.ACTIONS, |
| shortcuts: ['actions shortcuts'], |
| }, |
| ]); |
| assert.strictEqual(element._left.length, 0); |
| }); |
| |
| test('reply dialog goes on right', () => { |
| update(new Map([ |
| [kb.ShortcutSection.REPLY_DIALOG, ['reply dialog shortcuts']], |
| ])); |
| assert.deepEqual( |
| element._right, |
| [ |
| { |
| section: kb.ShortcutSection.REPLY_DIALOG, |
| shortcuts: ['reply dialog shortcuts'], |
| }, |
| ]); |
| assert.strictEqual(element._left.length, 0); |
| }); |
| |
| test('file list goes on right', () => { |
| update(new Map([ |
| [kb.ShortcutSection.FILE_LIST, ['file list shortcuts']], |
| ])); |
| assert.deepEqual( |
| element._right, |
| [ |
| { |
| section: kb.ShortcutSection.FILE_LIST, |
| shortcuts: ['file list shortcuts'], |
| }, |
| ]); |
| assert.strictEqual(element._left.length, 0); |
| }); |
| |
| test('diffs go on right', () => { |
| update(new Map([ |
| [kb.ShortcutSection.DIFFS, ['diffs shortcuts']], |
| ])); |
| assert.deepEqual( |
| element._right, |
| [ |
| { |
| section: kb.ShortcutSection.DIFFS, |
| shortcuts: ['diffs shortcuts'], |
| }, |
| ]); |
| assert.strictEqual(element._left.length, 0); |
| }); |
| |
| test('multiple sections on each side', () => { |
| update(new Map([ |
| [kb.ShortcutSection.ACTIONS, ['actions shortcuts']], |
| [kb.ShortcutSection.DIFFS, ['diffs shortcuts']], |
| [kb.ShortcutSection.EVERYWHERE, ['everywhere shortcuts']], |
| [kb.ShortcutSection.NAVIGATION, ['navigation shortcuts']], |
| ])); |
| assert.deepEqual( |
| element._left, |
| [ |
| { |
| section: kb.ShortcutSection.EVERYWHERE, |
| shortcuts: ['everywhere shortcuts'], |
| }, |
| { |
| section: kb.ShortcutSection.NAVIGATION, |
| shortcuts: ['navigation shortcuts'], |
| }, |
| ]); |
| assert.deepEqual( |
| element._right, |
| [ |
| { |
| section: kb.ShortcutSection.ACTIONS, |
| shortcuts: ['actions shortcuts'], |
| }, |
| { |
| section: kb.ShortcutSection.DIFFS, |
| shortcuts: ['diffs shortcuts'], |
| }, |
| ]); |
| }); |
| }); |
| }); |
| </script> |
| |