@rtif-sdk/test-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cory Robinson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @rtif-sdk/test-kit
2
+
3
+ Shared test utilities, document builders, and assertions for testing RTIF editors and plugins.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install --save-dev @rtif-sdk/test-kit
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Document builders
14
+
15
+ ```typescript
16
+ import { doc, block, span } from '@rtif-sdk/test-kit';
17
+
18
+ const testDoc = doc(
19
+ block('b1', 'text', span('Hello '), span('world', { bold: true })),
20
+ block('b2', 'text', span('')),
21
+ );
22
+ ```
23
+
24
+ ### Assertions
25
+
26
+ ```typescript
27
+ import { expectDocEqual, expectBlockCount, expectSpanText } from '@rtif-sdk/test-kit';
28
+
29
+ expectDocEqual(result, expected);
30
+ expectBlockCount(result, 2);
31
+ expectSpanText(result, 0, 0, 'Hello ');
32
+ ```
33
+
34
+ ### Fixtures
35
+
36
+ ```typescript
37
+ import { emptyDoc, singleBlockDoc, multiBlockDoc } from '@rtif-sdk/test-kit';
38
+
39
+ const empty = emptyDoc(); // single empty block
40
+ const single = singleBlockDoc(); // one block with text
41
+ const multi = multiBlockDoc(); // multiple blocks
42
+ ```
43
+
44
+ ## Peer Dependencies
45
+
46
+ - `vitest` ^4
47
+
48
+ ## License
49
+
50
+ MIT
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Custom test assertions for RTIF documents and selections.
3
+ */
4
+ import type { Document, Selection } from '@rtif-sdk/core';
5
+ /**
6
+ * Assert that two documents are structurally equal (ignoring block IDs).
7
+ */
8
+ export declare function assertDocEqual(_actual: Document, _expected: Document): void;
9
+ /**
10
+ * Assert that two selections are equal.
11
+ */
12
+ export declare function assertSelectionEqual(actual: Selection, expected: Selection): void;
13
+ //# sourceMappingURL=assertions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.d.ts","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE1D;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,IAAI,CAG3E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,GAAG,IAAI,CAUjF"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Custom test assertions for RTIF documents and selections.
3
+ */
4
+ /**
5
+ * Assert that two documents are structurally equal (ignoring block IDs).
6
+ */
7
+ export function assertDocEqual(_actual, _expected) {
8
+ // TODO: Implement deep structural comparison
9
+ throw new Error('assertDocEqual() not yet implemented');
10
+ }
11
+ /**
12
+ * Assert that two selections are equal.
13
+ */
14
+ export function assertSelectionEqual(actual, expected) {
15
+ if (actual.anchor.offset !== expected.anchor.offset ||
16
+ actual.focus.offset !== expected.focus.offset) {
17
+ throw new Error(`Selection mismatch: got (${actual.anchor.offset}, ${actual.focus.offset}), ` +
18
+ `expected (${expected.anchor.offset}, ${expected.focus.offset})`);
19
+ }
20
+ }
21
+ //# sourceMappingURL=assertions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.js","sourceRoot":"","sources":["../src/assertions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAiB,EAAE,SAAmB;IACnE,6CAA6C;IAC7C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,QAAmB;IACzE,IACE,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC,MAAM;QAC/C,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,KAAK,CAAC,MAAM,EAC7C,CAAC;QACD,MAAM,IAAI,KAAK,CACb,4BAA4B,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK;YAC3E,aAAa,QAAQ,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,KAAK,CAAC,MAAM,GAAG,CACnE,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Fluent document builders for tests.
3
+ * See SPEC.md Appendix C for usage examples.
4
+ */
5
+ import type { Document, Selection } from '@rtif-sdk/core';
6
+ /** Builder for constructing test documents fluently */
7
+ export declare class DocumentBuilder {
8
+ private blocks;
9
+ private nextId;
10
+ /**
11
+ * Add a block with plain text, or text with marks.
12
+ *
13
+ * Usage:
14
+ * doc().block("Hello")
15
+ * doc().block("Hello ", { bold: "world" })
16
+ */
17
+ block(text: string, _marks?: Record<string, string>): this;
18
+ /** Build the final Document */
19
+ build(): Document;
20
+ }
21
+ /** Create a new DocumentBuilder */
22
+ export declare function doc(): DocumentBuilder;
23
+ /** Create a Selection from anchor and focus offsets */
24
+ export declare function sel(anchor: number, focus: number): Selection;
25
+ //# sourceMappingURL=builders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAS,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEjE,uDAAuD;AACvD,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAK;IAEnB;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAW1D,+BAA+B;IAC/B,KAAK,IAAI,QAAQ;CAUlB;AAED,mCAAmC;AACnC,wBAAgB,GAAG,IAAI,eAAe,CAErC;AAED,uDAAuD;AACvD,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,CAK5D"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Fluent document builders for tests.
3
+ * See SPEC.md Appendix C for usage examples.
4
+ */
5
+ /** Builder for constructing test documents fluently */
6
+ export class DocumentBuilder {
7
+ blocks = [];
8
+ nextId = 1;
9
+ /**
10
+ * Add a block with plain text, or text with marks.
11
+ *
12
+ * Usage:
13
+ * doc().block("Hello")
14
+ * doc().block("Hello ", { bold: "world" })
15
+ */
16
+ block(text, _marks) {
17
+ // TODO: Implement mark parsing from the shorthand format
18
+ // For now, creates a simple single-span block
19
+ this.blocks.push({
20
+ id: `b${this.nextId++}`,
21
+ type: 'text',
22
+ spans: [{ text }],
23
+ });
24
+ return this;
25
+ }
26
+ /** Build the final Document */
27
+ build() {
28
+ if (this.blocks.length === 0) {
29
+ this.blocks.push({
30
+ id: 'b1',
31
+ type: 'text',
32
+ spans: [{ text: '' }],
33
+ });
34
+ }
35
+ return { version: 1, blocks: this.blocks };
36
+ }
37
+ }
38
+ /** Create a new DocumentBuilder */
39
+ export function doc() {
40
+ return new DocumentBuilder();
41
+ }
42
+ /** Create a Selection from anchor and focus offsets */
43
+ export function sel(anchor, focus) {
44
+ return {
45
+ anchor: { offset: anchor },
46
+ focus: { offset: focus },
47
+ };
48
+ }
49
+ //# sourceMappingURL=builders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builders.js","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,uDAAuD;AACvD,MAAM,OAAO,eAAe;IAClB,MAAM,GAAY,EAAE,CAAC;IACrB,MAAM,GAAG,CAAC,CAAC;IAEnB;;;;;;OAMG;IACH,KAAK,CAAC,IAAY,EAAE,MAA+B;QACjD,yDAAyD;QACzD,8CAA8C;QAC9C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACf,EAAE,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE;YACvB,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC;SAClB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+BAA+B;IAC/B,KAAK;QACH,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;gBACf,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;aACtB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IAC7C,CAAC;CACF;AAED,mCAAmC;AACnC,MAAM,UAAU,GAAG;IACjB,OAAO,IAAI,eAAe,EAAE,CAAC;AAC/B,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,KAAa;IAC/C,OAAO;QACL,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;QAC1B,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;KACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { doc, sel, DocumentBuilder } from './builders.js';
2
+ export { assertDocEqual, assertSelectionEqual } from './assertions.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { doc, sel, DocumentBuilder } from './builders.js';
2
+ export { assertDocEqual, assertSelectionEqual } from './assertions.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@rtif-sdk/test-kit",
3
+ "version": "1.0.0",
4
+ "description": "RTIF shared test utilities, builders, and assertions",
5
+ "author": "coryrobinson42@gmail.com",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist"],
16
+ "sideEffects": false,
17
+ "engines": { "node": ">=20.0.0" },
18
+ "keywords": ["rtif", "test-utilities", "rich-text", "editor-testing"],
19
+ "scripts": {
20
+ "build": "tsc --build tsconfig.build.json",
21
+ "test": "vitest run",
22
+ "prepublishOnly": "npm run build"
23
+ },
24
+ "dependencies": {
25
+ "@rtif-sdk/core": "^1.0.0"
26
+ },
27
+ "peerDependencies": {
28
+ "vitest": "^4"
29
+ },
30
+ "license": "MIT"
31
+ }