-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathblocks-delete-contract.test.ts
More file actions
30 lines (26 loc) · 1.12 KB
/
blocks-delete-contract.test.ts
File metadata and controls
30 lines (26 loc) · 1.12 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
import { describe, expect, it } from 'bun:test';
import { executeBlocksDelete, type BlocksAdapter } from '../blocks/blocks.js';
import type { BlocksDeleteResult } from '../types/blocks.types.js';
import { DocumentApiValidationError } from '../errors.js';
import { OPERATION_DEFINITIONS } from './operation-definitions.js';
function makeAdapter(result?: BlocksDeleteResult): BlocksAdapter {
const defaultResult: BlocksDeleteResult = {
success: true,
deleted: { kind: 'block', nodeType: 'paragraph', nodeId: 'p1' },
};
return {
delete: () => result ?? defaultResult,
};
}
describe('blocks.delete contract metadata', () => {
it('declares INVALID_INPUT in throws.preApply for malformed input', () => {
try {
executeBlocksDelete(makeAdapter(), null as never);
expect.unreachable('expected INVALID_INPUT validation error');
} catch (error) {
expect(error).toBeInstanceOf(DocumentApiValidationError);
expect((error as DocumentApiValidationError).code).toBe('INVALID_INPUT');
}
expect(OPERATION_DEFINITIONS['blocks.delete'].metadata.throws.preApply).toContain('INVALID_INPUT');
});
});