UNPKG

2.7 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2019 Ericsson and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18const jsdom_1 = require("../test/jsdom");
19let disableJSDOM = (0, jsdom_1.enableJSDOM)();
20const chai_1 = require("chai");
21const widgets_1 = require("@phosphor/widgets");
22const tab_bars_1 = require("./tab-bars");
23disableJSDOM();
24describe('tab bar', () => {
25 before(() => {
26 disableJSDOM = (0, jsdom_1.enableJSDOM)();
27 });
28 after(() => {
29 disableJSDOM();
30 });
31 it('should disambiguate tabs that have identical names', () => {
32 const tabBar = new tab_bars_1.TabBarRenderer();
33 const owner = new widgets_1.Widget();
34 const tabLabels = ['index.ts', 'index.ts', 'index.ts', 'main.ts', 'main.ts', 'main.ts', 'uniqueFile.ts'];
35 const tabPaths = [
36 'root1/src/foo/bar/index.ts',
37 'root1/lib/foo/bar/index.ts',
38 'root2/src/foo/goo/bar/index.ts',
39 'root1/aaa/main.ts',
40 'root1/aaa/bbb/main.ts',
41 'root1/aaa/bbb/ccc/main.ts',
42 'root1/src/foo/bar/uniqueFile.ts'
43 ];
44 const tabs = tabLabels.map((label, i) => new widgets_1.Title({
45 owner, label, caption: tabPaths[i]
46 }));
47 const pathMap = tabBar.findDuplicateLabels(tabs);
48 (0, chai_1.expect)(pathMap.get(tabPaths[0])).to.be.equal('.../src/...');
49 (0, chai_1.expect)(pathMap.get(tabPaths[1])).to.be.equal('.../lib/...');
50 (0, chai_1.expect)(pathMap.get(tabPaths[2])).to.be.equal('root2/...');
51 (0, chai_1.expect)(pathMap.get(tabPaths[3])).to.be.equal('root1/aaa');
52 (0, chai_1.expect)(pathMap.get(tabPaths[4])).to.be.equal('root1/aaa/bbb');
53 (0, chai_1.expect)(pathMap.get(tabPaths[5])).to.be.equal('.../ccc');
54 (0, chai_1.expect)(pathMap.get(tabPaths[6])).to.be.equal(undefined);
55 });
56});
57//# sourceMappingURL=tab-bars.spec.js.map
\No newline at end of file