-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathclear-content.test.ts
More file actions
31 lines (24 loc) · 1.1 KB
/
clear-content.test.ts
File metadata and controls
31 lines (24 loc) · 1.1 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
import { describe, expect, it, mock } from 'bun:test';
import { executeClearContent } from './clear-content.js';
import type { ClearContentAdapter } from './clear-content.js';
import type { Receipt } from '../types/receipt.js';
const SUCCESS_RECEIPT: Receipt = { success: true };
const NOOP_RECEIPT: Receipt = { success: false, failure: { code: 'NO_OP', message: 'Document is already empty.' } };
describe('executeClearContent', () => {
it('delegates to adapter.clearContent with input and options', () => {
const adapter: ClearContentAdapter = {
clearContent: mock(() => SUCCESS_RECEIPT),
};
const result = executeClearContent(adapter, {}, { expectedRevision: 'r1' });
expect(result).toBe(SUCCESS_RECEIPT);
expect(adapter.clearContent).toHaveBeenCalledWith({}, { expectedRevision: 'r1' });
});
it('returns adapter result when NO_OP', () => {
const adapter: ClearContentAdapter = {
clearContent: mock(() => NOOP_RECEIPT),
};
const result = executeClearContent(adapter, {});
expect(result).toEqual(NOOP_RECEIPT);
expect(result.success).toBe(false);
});
});