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 jsdom_1 = require("../test/jsdom");
|
19 | let disableJSDOM = (0, jsdom_1.enableJSDOM)();
|
20 | const chai_1 = require("chai");
|
21 | const widgets_1 = require("@phosphor/widgets");
|
22 | const tab_bars_1 = require("./tab-bars");
|
23 | disableJSDOM();
|
24 | describe('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 |
|
\ | No newline at end of file |