-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
breadcrumb_container_unittest.ts
68 lines (58 loc) · 1.99 KB
/
breadcrumb_container_unittest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {assertEquals, assertNotEquals} from 'chrome://webui-test/chai_assert.js';
import {CurrentDirectory, PropStatus} from '../externs/ts/state.js';
import {getEmptyState, getStore} from '../state/store.js';
import {BreadcrumbContainer} from './breadcrumb_container.js';
/** An instance of BreadcrumbContainer. */
let breadcrumbContainer: BreadcrumbContainer|null = null;
export function setUp() {
document.body.innerHTML = '<div id="breadcrumb-container"></div>';
breadcrumbContainer =
new BreadcrumbContainer(document.querySelector('#breadcrumb-container')!);
}
/**
* Tests that when current directory has "/" in the path, it will be escaped
* before passing to the underlying breadcrumb.
*/
export function testPathWithSlash(done: () => void) {
const store = getStore();
store.init(getEmptyState());
const currentDirectory: CurrentDirectory = {
key: 'filesystem:chrome://file-manager/external/aaa/bbb',
status: PropStatus.SUCCESS,
rootType: undefined,
pathComponents: [
{name: 'Nexus/Pixel(MTP)', label: 'Nexus/Pixel(MTP)', key: ''},
{name: 'DCIM', label: 'DCIM', key: ''},
],
content: {
keys: [],
},
selection: {
keys: [],
dirCount: 0,
fileCount: 0,
hostedCount: undefined,
offlineCachedCount: undefined,
fileTasks: {
policyDefaultHandlerStatus: undefined,
defaultTask: undefined,
tasks: [],
status: PropStatus.SUCCESS,
},
},
hasDlpDisabledFiles: false,
};
// Simulate a state change from the store.
breadcrumbContainer!.onStateChanged({...store.getState(), currentDirectory});
// Check that breadcrumb's path has been escaped.
const breadcrumb = document.querySelector('xf-breadcrumb');
assertNotEquals(null, breadcrumb);
assertEquals(
breadcrumb!.path,
'Nexus%2FPixel(MTP)/DCIM',
);
done();
}