1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const command_1 = require("../command");
|
19 | const menu_model_registry_1 = require("./menu-model-registry");
|
20 | const chai = require("chai");
|
21 | const expect = chai.expect;
|
22 | describe('menu-model-registry', () => {
|
23 | describe('01 #register', () => {
|
24 | it('Should allow to register menu actions.', () => {
|
25 | const fileMenu = ['main', 'File'];
|
26 | const fileOpenMenu = [...fileMenu, '0_open'];
|
27 | const service = createMenuRegistry({
|
28 | registerMenus(menuRegistry) {
|
29 | menuRegistry.registerSubmenu(fileMenu, 'File');
|
30 | menuRegistry.registerMenuAction(fileOpenMenu, {
|
31 | commandId: 'open'
|
32 | });
|
33 | menuRegistry.registerMenuAction(fileOpenMenu, {
|
34 | commandId: 'open.with'
|
35 | });
|
36 | }
|
37 | }, {
|
38 | registerCommands(reg) {
|
39 | reg.registerCommand({
|
40 | id: 'open',
|
41 | label: 'A'
|
42 | });
|
43 | reg.registerCommand({
|
44 | id: 'open.with',
|
45 | label: 'B'
|
46 | });
|
47 | }
|
48 | });
|
49 | const all = service.getMenu();
|
50 | const main = all.children[0];
|
51 | expect(main.children.length).equals(1);
|
52 | expect(main.id, 'main');
|
53 | expect(all.children.length).equals(1);
|
54 | const file = main.children[0];
|
55 | expect(file.children.length).equals(1);
|
56 | expect(file.label, 'File');
|
57 | const openGroup = file.children[0];
|
58 | expect(openGroup.children.length).equals(2);
|
59 | expect(openGroup.label).undefined;
|
60 | });
|
61 | });
|
62 | });
|
63 | function createMenuRegistry(menuContrib, commandContrib) {
|
64 | const cmdReg = new command_1.CommandRegistry({ getContributions: () => [commandContrib] });
|
65 | cmdReg.onStart();
|
66 | const menuReg = new menu_model_registry_1.MenuModelRegistry({ getContributions: () => [menuContrib] }, cmdReg);
|
67 | menuReg.onStart();
|
68 | return menuReg;
|
69 | }
|
70 |
|
\ | No newline at end of file |