一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
57 行
1.3 KiB
TypeScript
57 行
1.3 KiB
TypeScript
const sandboxProxy = require('@joplin/lib/services/plugins/sandboxProxy');
|
|
import { setupDatabaseAndSynchronizer, switchClient } from '@joplin/lib/testing/test-utils';
|
|
|
|
describe('services_plugins_sandboxProxy', () => {
|
|
|
|
beforeEach(async () => {
|
|
await setupDatabaseAndSynchronizer(1);
|
|
await switchClient(1);
|
|
});
|
|
|
|
it('should create a new sandbox proxy', (async () => {
|
|
interface Result {
|
|
path: string;
|
|
args: unknown[];
|
|
}
|
|
|
|
const results: Result[] = [];
|
|
|
|
const target = (path: string, args: unknown[]) => {
|
|
results.push({ path, args });
|
|
};
|
|
|
|
const proxy = sandboxProxy(target);
|
|
|
|
proxy.testing.bla.test('hello', '123');
|
|
proxy.testing.test2();
|
|
|
|
expect(results[0].path).toBe('testing.bla.test');
|
|
expect(results[0].args.join('_')).toBe('hello_123');
|
|
expect(results[1].path).toBe('testing.test2');
|
|
expect(results[1].args.join('_')).toBe('');
|
|
}));
|
|
|
|
it('should allow importing a namespace', (async () => {
|
|
interface Result {
|
|
path: string;
|
|
args: unknown[];
|
|
}
|
|
|
|
const results: Result[] = [];
|
|
|
|
const target = (path: string, args: unknown[]) => {
|
|
results.push({ path, args });
|
|
};
|
|
|
|
const proxy = sandboxProxy(target);
|
|
|
|
const ns = proxy.testing.blabla;
|
|
ns.test();
|
|
ns.test2();
|
|
|
|
expect(results[0].path).toBe('testing.blabla.test');
|
|
expect(results[1].path).toBe('testing.blabla.test2');
|
|
}));
|
|
|
|
});
|