fix(preview-download): declare remote service dependency
This commit is contained in:
@@ -45,3 +45,27 @@ test('plugin registers only the supported preview action slot', () => {
|
||||
assert.equal(registration.id, 'dsh-preview-download');
|
||||
assert.equal(typeof registration.inject('session-A').download, 'function');
|
||||
});
|
||||
|
||||
test('registered download declares every service used by its callback', async () => {
|
||||
const plugin = load();
|
||||
assert.ok(plugin.inject.includes('remote'));
|
||||
assert.ok(plugin.inject.includes('remote.workspaceFiles'));
|
||||
let registration;
|
||||
let calls = 0;
|
||||
const data = new Uint8Array([1, 2, 255]);
|
||||
const ctx = {
|
||||
effect: fn => fn(),
|
||||
locale: { register: () => () => {} },
|
||||
slots: { inject: (_name, fn) => fn(), register(options) { registration = options; return () => {}; } },
|
||||
get remote() {
|
||||
assert.ok(plugin.inject.includes('remote'), 'Cordis requires explicit remote injection');
|
||||
return { workspaceFiles: { async readBytes(session, path) {
|
||||
assert.equal(session, 'session-A'); assert.equal(path, '/file.bin'); calls++;
|
||||
return { ok: true, value: { offset: 0, eof: true, bytes: 3, data } };
|
||||
} } };
|
||||
}
|
||||
};
|
||||
plugin.apply(ctx);
|
||||
assert.equal(await registration.inject('session-A').download('/file.bin', new AbortController().signal), data);
|
||||
assert.equal(calls, 1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user