UNPKG

@unito/integration-sdk

Version:

Integration SDK

35 lines (25 loc) 1.29 kB
# richTextFixtures A corpus of canonical RichText ASTs known to be problematic for codec implementations — nested lists, headers-in-list, soft breaks, mentions, empty formatting, link-with-quote, malformed input, etc. ## Why Every rich-text codec hits the same edge cases. This module collects those shapes once, in canonical AST form, so a new integration inherits the catalog instead of rediscovering each shape via production incidents. ## Usage ```ts import { canonicalFixtures } from '@unito/integration-sdk/richTextFixtures'; for (const [name, ast] of Object.entries(canonicalFixtures)) { // Run whatever assertion your integration's codec needs. // E.g. snapshot the serializer output of one of your fields: assert.equal(yourField.serialize(ast), readFileSync(`./snapshots/${name}.txt`, 'utf-8')); } ``` How you organise your tests — snapshot layout, which fields you cover, how you generate expected outputs — is up to the integration. The SDK only provides the corpus. ## Catching silent gaps If you want every fixture to have a declared expected output (so a codec can't accidentally ship doing nothing on, say, nested lists), let `readFileSync` throw on the missing snapshot path. The ENOENT path points at exactly the file the engineer needs to populate.