mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
lint + prettier
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
* an RPC call, config is frozen, and log is a fire-and-forget event. Runs
|
||||
* in-process against a fake transport (no fork needed).
|
||||
*/
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { createPluginContext, definePlugin, type ChildTransport } from '../../../src/nest/plugins/runtime/plugin-sdk';
|
||||
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
function fakeTransport() {
|
||||
const rpc = vi.fn(async () => ({ ok: true }));
|
||||
const emit = vi.fn();
|
||||
@@ -30,7 +31,11 @@ describe('createPluginContext', () => {
|
||||
expect(rpc).toHaveBeenCalledWith('trips.getById', { tripId: 1, _inv: 'inv-1' });
|
||||
|
||||
await ctx.journal.addEntryPhoto(5, { name: 'a.jpg', content_base64: 'eA==' });
|
||||
expect(rpc).toHaveBeenCalledWith('journal.addEntryPhoto', { entryId: 5, input: { name: 'a.jpg', content_base64: 'eA==' }, _inv: 'inv-1' });
|
||||
expect(rpc).toHaveBeenCalledWith('journal.addEntryPhoto', {
|
||||
entryId: 5,
|
||||
input: { name: 'a.jpg', content_base64: 'eA==' },
|
||||
_inv: 'inv-1',
|
||||
});
|
||||
|
||||
await ctx.ws.broadcastToTrip(1, 'ping', { a: 1 });
|
||||
// carries _inv so the host can bind the acting user — without it the broadcast was refused
|
||||
@@ -58,7 +63,12 @@ describe('createPluginContext', () => {
|
||||
expect(rpc).toHaveBeenCalledWith('costs.create', { tripId: 1, input: { name: 'Hotel' }, _inv: 'inv-1' });
|
||||
|
||||
await ctx.costs.update(1, 5, { name: 'Hostel' });
|
||||
expect(rpc).toHaveBeenCalledWith('costs.update', { tripId: 1, itemId: 5, input: { name: 'Hostel' }, _inv: 'inv-1' });
|
||||
expect(rpc).toHaveBeenCalledWith('costs.update', {
|
||||
tripId: 1,
|
||||
itemId: 5,
|
||||
input: { name: 'Hostel' },
|
||||
_inv: 'inv-1',
|
||||
});
|
||||
|
||||
await ctx.costs.delete(1, 5);
|
||||
expect(rpc).toHaveBeenCalledWith('costs.delete', { tripId: 1, itemId: 5, _inv: 'inv-1' });
|
||||
|
||||
Reference in New Issue
Block a user