forked from libapps/libapps-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhterm_contextmenu_tests.js
More file actions
55 lines (44 loc) · 1.32 KB
/
hterm_contextmenu_tests.js
File metadata and controls
55 lines (44 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview hterm.ContextMenu unit tests.
*/
import {hterm} from '../index.js';
/**
* Verify we can show/hide an empty menu.
*/
it('contextmenu-stub', () => {
const menu = new hterm.ContextMenu();
// Show/hide this stub menu. It should be fine.
menu.show(/** @type {!Event} */ ({clientX: 0, clientY: 0}));
menu.hide();
});
/**
* Verify we can show/hide a simple menu.
*/
it('contextmenu-simple', () => {
const document = globalThis.document;
const menu = new hterm.ContextMenu();
menu.setDocument(document);
// Create a basic menu.
menu.setItems([{name: 'Foo', action: () => {}}]);
// Show/hide this menu.
menu.show(/** @type {!Event} */ ({clientX: 0, clientY: 0}));
menu.hide();
});
/**
* Check separator handling.
*/
it('contextmenu-separator', () => {
const document = globalThis.document;
const menu = new hterm.ContextMenu();
menu.setDocument(document);
// Create a basic menu.
menu.setItems([{name: hterm.ContextMenu.SEPARATOR}]);
// Check the entries.
assert.equal('separator', menu.element_.firstElementChild.className);
// Show/hide this menu.
menu.show(/** @type {!Event} */ ({clientX: 0, clientY: 0}));
menu.hide();
});