UNPKG

3.48 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2019 TypeFox 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 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 tab_bar_toolbar_types_1 = require("./tab-bar-toolbar-types");
22disableJSDOM();
23describe('tab-bar-toolbar', () => {
24 describe('comparator', () => {
25 before(() => {
26 disableJSDOM = (0, jsdom_1.enableJSDOM)();
27 });
28 after(() => {
29 disableJSDOM();
30 });
31 const testMe = tab_bar_toolbar_types_1.TabBarToolbarItem.PRIORITY_COMPARATOR;
32 it("should favour the 'navigation' group before everything else", () => {
33 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', group: 'navigation' }, { id: 'b', command: 'b', group: 'other' })).to.be.equal(-1);
34 });
35 it("should treat 'undefined' groups as 'navigation'", () => {
36 (0, chai_1.expect)(testMe({ id: 'a', command: 'a' }, { id: 'b', command: 'b' })).to.be.equal(0);
37 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', group: 'navigation' }, { id: 'b', command: 'b' })).to.be.equal(0);
38 (0, chai_1.expect)(testMe({ id: 'a', command: 'a' }, { id: 'b', command: 'b', group: 'navigation' })).to.be.equal(0);
39 (0, chai_1.expect)(testMe({ id: 'a', command: 'a' }, { id: 'b', command: 'b', group: 'other' })).to.be.equal(-1);
40 });
41 it("should fall back to 'priority' if the groups are the same", () => {
42 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', priority: 1 }, { id: 'b', command: 'b', priority: 2 })).to.be.equal(-1);
43 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', group: 'navigation', priority: 1 }, { id: 'b', command: 'b', priority: 2 })).to.be.equal(-1);
44 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', priority: 1 }, { id: 'b', command: 'b', group: 'navigation', priority: 2 })).to.be.equal(-1);
45 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', priority: 1, group: 'other' }, { id: 'b', command: 'b', priority: 2 })).to.be.equal(1);
46 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', group: 'other', priority: 1 }, { id: 'b', command: 'b', priority: 2, group: 'other' })).to.be.equal(-1);
47 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', priority: 10 }, { id: 'b', command: 'b', group: 'other', priority: 2 })).to.be.equal(-1);
48 (0, chai_1.expect)(testMe({ id: 'a', command: 'a', group: 'other', priority: 10 }, { id: 'b', command: 'b', group: 'other', priority: 10 })).to.be.equal(0);
49 });
50 });
51});
52//# sourceMappingURL=tab-bar-toolbar.spec.js.map
\No newline at end of file