Skip to content

Commit efaf401

Browse files
committed
test: client: key: insert
1 parent d76e5dc commit efaf401

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎.madrun.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import {defineEnv} from 'supertape/env';
44
const testEnv = defineEnv({
55
timeout: 7000,
66
css: true,
7+
}, {
8+
env: {
9+
NODE_OPTIONS: '--localstorage-file /tmp/cloudcmd-localstorage',
10+
},
711
});
812

913
const buildEnv = {

‎client/dom/cmd.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* global DOM */
21
const SELECTED_FILE = 'selected-file';
2+
const {DOM} = globalThis;
33

44
/**
55
* selected file check

‎client/key/index.spec.js‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ test('cloudcmd: client: key: disable vim', async (t) => {
6161
});
6262

6363
test('cloudcmd: key: Insert: toggles selection of current file', async (t) => {
64-
const toggleSelectedFile = stub().returns({});
6564
const setCurrentFile = stub();
65+
const toggleSelectedFile = stub().returns({
66+
setCurrentFile,
67+
});
68+
6669
const next = {};
70+
const {DOM} = globalThis;
6771

6872
globalThis.DOM = {
6973
...getDOM(),
@@ -85,13 +89,16 @@ test('cloudcmd: key: Insert: toggles selection of current file', async (t) => {
8589
preventDefault: noop,
8690
});
8791

92+
globalThis.DOM = DOM;
93+
8894
t.calledOnce(toggleSelectedFile, 'should toggle selection');
8995
t.end();
9096
});
9197

9298
test('cloudcmd: key: Insert: moves cursor to next file', async (t) => {
9399
const next = {};
94100
const setCurrentFile = stub();
101+
const {DOM} = globalThis;
95102

96103
globalThis.DOM = {
97104
...getDOM(),
@@ -104,15 +111,18 @@ test('cloudcmd: key: Insert: moves cursor to next file', async (t) => {
104111
panel: {},
105112
path: '/a.txt',
106113
},
107-
toggleSelectedFile: stub().returns({}),
108-
setCurrentFile,
114+
toggleSelectedFile: stub().returns({
115+
setCurrentFile,
116+
}),
109117
};
110118

111119
await _switchKey({
112120
keyCode: INSERT,
113121
preventDefault: noop,
114122
});
115123

124+
globalThis.DOM = DOM;
125+
116126
t.calledWith(setCurrentFile, [next], 'should move cursor to next');
117127
t.end();
118128
});

0 commit comments

Comments
 (0)