UNPKG

2.35 kBPlain TextView Raw
1// *****************************************************************************
2// Copyright (C) 2022 Ericsson and others.
3//
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License v. 2.0 which is available at
6// http://www.eclipse.org/legal/epl-2.0.
7//
8// This Source Code may also be made available under the following Secondary
9// Licenses when the conditions for such availability set forth in the Eclipse
10// Public License v. 2.0 are satisfied: GNU General Public License, version 2
11// with the GNU Classpath Exception which is available at
12// https://www.gnu.org/software/classpath/license.html.
13//
14// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15// *****************************************************************************
16
17import * as assert from 'assert';
18import { Container } from 'inversify';
19import { createTreeContainer, isTreeServices } from './tree-container';
20import { TreeSearch } from './tree-search';
21import { defaultTreeProps, TreeProps } from './tree-widget';
22
23describe('TreeContainer', () => {
24 describe('IsTreeServices should accurately distinguish TreeProps from TreeContainerProps', () => {
25 it('should assign search:boolean to TreeProps', () => {
26 assert(isTreeServices({
27 ...defaultTreeProps, search: true, multiSelect: true, globalSelection: true, contextMenuPath: ['so-contextual']
28 }) === false);
29 });
30 it('should assign search:not-a-boolean to TreeContainerProps', () => {
31 assert(isTreeServices({ search: TreeSearch }) === true);
32 });
33 const nonDefault = { search: !defaultTreeProps.search, contextMenu: ['no-default-for-this'] };
34 it('should use props passed in as just props', () => {
35 const parent = new Container();
36 const child = createTreeContainer(parent, nonDefault);
37 assert.deepStrictEqual(child.get(TreeProps), { ...defaultTreeProps, ...nonDefault });
38 });
39 it('should use props passed in as part of TreeContainerProps', () => {
40 const parent = new Container();
41 const child = createTreeContainer(parent, { props: nonDefault });
42 assert.deepStrictEqual(child.get(TreeProps), { ...defaultTreeProps, ...nonDefault });
43 });
44 });
45});