UNPKG

2.64 kBPlain TextView Raw
1// *****************************************************************************
2// Copyright (C) 2017 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 { expect } from 'chai';
18import { DefaultUriLabelProviderContribution, URIIconReference } from './label-provider';
19import URI from '../common/uri';
20import { OS } from '../common/os';
21
22describe('DefaultUriLabelProviderContribution', function (): void {
23
24 it('should return a short name', function (): void {
25 const prov = new DefaultUriLabelProviderContribution();
26 const shortName = prov.getName(new URI('file:///tmp/hello/you.txt'));
27
28 expect(shortName).eq('you.txt');
29 });
30
31 it('should return a long name', function (): void {
32 const prov = new DefaultUriLabelProviderContribution();
33 const longName = prov.getLongName(new URI('file:///tmp/hello/you.txt'));
34
35 if (OS.backend.isWindows) {
36 expect(longName).eq('\\tmp\\hello\\you.txt');
37 } else {
38 expect(longName).eq('/tmp/hello/you.txt');
39 }
40 });
41
42 it('should return icon class for something that seems to be a file', function (): void {
43 const prov = new DefaultUriLabelProviderContribution();
44 const icon = prov.getIcon(new URI('file:///tmp/hello/you.txt'));
45
46 expect(icon).eq('text-icon medium-blue theia-file-icons-js');
47 });
48
49 it('should return file icon class for something that seems to be a directory', function (): void {
50 const prov = new DefaultUriLabelProviderContribution();
51 const icon = prov.getIcon(new URI('file:///tmp/hello'));
52
53 expect(icon).eq(prov.defaultFileIcon);
54 });
55
56 it('should return folder icon class for something that is a directory', function (): void {
57 const prov = new DefaultUriLabelProviderContribution();
58 const icon = prov.getIcon(URIIconReference.create('folder', new URI('file:///tmp/hello')));
59
60 expect(icon).eq(prov.defaultFolderIcon);
61 });
62});