@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
68 lines • 4.24 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// *****************************************************************************
// Copyright (C) 2024 EclipseSource and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
const chai_1 = require("chai");
const composite_menu_node_1 = require("./composite-menu-node");
describe('composite-menu-node', () => {
describe('updateOptions', () => {
it('should update undefined node properties', () => {
const node = new composite_menu_node_1.CompositeMenuNode('test-id');
node.updateOptions({ label: 'node-label', icon: 'icon', order: 'a', role: 2 /* CompoundMenuNodeRole.Flat */, when: 'node-condition' });
(0, chai_1.expect)(node.label).to.equal('node-label');
(0, chai_1.expect)(node.icon).to.equal('icon');
(0, chai_1.expect)(node.order).to.equal('a');
(0, chai_1.expect)(node.role).to.equal(2 /* CompoundMenuNodeRole.Flat */);
(0, chai_1.expect)(node.when).to.equal('node-condition');
});
it('should update existing node properties', () => {
const node = new composite_menu_node_1.CompositeMenuNode('test-id', 'test-label', { icon: 'test-icon', order: 'a1', role: 0 /* CompoundMenuNodeRole.Submenu */, when: 'test-condition' });
node.updateOptions({ label: 'NEW-label', icon: 'NEW-icon', order: 'a2', role: 2 /* CompoundMenuNodeRole.Flat */, when: 'NEW-condition' });
(0, chai_1.expect)(node.label).to.equal('NEW-label');
(0, chai_1.expect)(node.icon).to.equal('NEW-icon');
(0, chai_1.expect)(node.order).to.equal('a2');
(0, chai_1.expect)(node.role).to.equal(2 /* CompoundMenuNodeRole.Flat */);
(0, chai_1.expect)(node.when).to.equal('NEW-condition');
});
it('should update only the icon without affecting other properties', () => {
const node = new composite_menu_node_1.CompositeMenuNode('test-id', 'test-label', { icon: 'test-icon', order: 'a' });
node.updateOptions({ icon: 'NEW-icon' });
(0, chai_1.expect)(node.label).to.equal('test-label');
(0, chai_1.expect)(node.icon).to.equal('NEW-icon');
(0, chai_1.expect)(node.order).to.equal('a');
});
it('should not allow to unset properties', () => {
const node = new composite_menu_node_1.CompositeMenuNode('test-id', 'test-label', { icon: 'test-icon', order: 'a' });
node.updateOptions({ icon: undefined });
(0, chai_1.expect)(node.label).to.equal('test-label');
(0, chai_1.expect)(node.icon).to.equal('test-icon');
(0, chai_1.expect)(node.order).to.equal('a');
});
it('should allow to set empty strings in properties', () => {
const node = new composite_menu_node_1.CompositeMenuNode('test-id', 'test-label');
node.updateOptions({ label: '' });
(0, chai_1.expect)(node.label).to.equal('');
});
it('should not cause side effects when updating a property to its existing value', () => {
const node = new composite_menu_node_1.CompositeMenuNode('test-id', 'test-label', { icon: 'test-icon', order: 'a' });
node.updateOptions({ icon: 'test-icon' });
(0, chai_1.expect)(node.label).to.equal('test-label');
(0, chai_1.expect)(node.icon).to.equal('test-icon');
(0, chai_1.expect)(node.order).to.equal('a');
});
});
});
//# sourceMappingURL=composite-menu-node.spec.js.map