forked from ignaci0/appimage-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
52 lines (50 loc) · 1.35 KB
/
jest.setup.js
File metadata and controls
52 lines (50 loc) · 1.35 KB
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
const mockFile = {
query_exists: jest.fn(() => false),
make_directory_with_parents: jest.fn(() => { throw new Error('Mock error'); }),
monitor_directory: jest.fn(() => ({
connect: jest.fn(),
cancel: jest.fn(),
})),
replace_contents: jest.fn(() => { throw new Error('Mock error'); }),
delete: jest.fn(() => { throw new Error('Mock error'); }),
query_info: jest.fn(() => ({
get_permissions: jest.fn(() => ({})),
})),
set_attribute_uint32: jest.fn(),
get_path: jest.fn(path => `/home/user/.local/share/applications`),
load_contents: jest.fn(() => [false, null]),
};
global.imports = {
gi: {
Gio: {
File: {
new_for_path: jest.fn(path => mockFile),
},
FileMonitorFlags: {
NONE: 0,
},
FileMonitorEvent: {
CHANGES_DONE_HINT: 0,
FILE_CREATED: 1,
FILE_DELETED: 2,
},
FilePermission: {
EXECUTE: 1,
},
FileQueryInfoFlags: {
NONE: 0,
},
FileCreateFlags: {
REPLACE_DESTINATION: 1,
},
},
GLib: {
get_home_dir: jest.fn(() => '/home/user'),
get_user_data_dir: jest.fn(() => '/home/user/.local/share'),
build_pathv: jest.fn((sep, paths) => paths.join(sep)),
path_get_basename: jest.fn(path => path.split('/').pop()),
},
},
};
global.log = jest.fn();
global.logError = jest.fn();