@optimizely-opal/opal-tools-sdk 0.1.6-dev → 0.1.9-dev

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.
@@ -1,115 +0,0 @@
1
- /**
2
- * Tests for Adaptive Block components
3
- */
4
-
5
- import { describe, expect, test } from "vitest";
6
-
7
- import type { BlockResponse } from "../src";
8
-
9
- import { Block } from "../src";
10
-
11
- describe("Block Components", () => {
12
- test("Block.Heading with children", () => {
13
- const heading = Block.Heading({ children: "Test Heading" });
14
- expect(heading.$type).toBe("Block.Heading");
15
-
16
- const response: BlockResponse = {
17
- content: Block.Document({ children: heading }),
18
- };
19
- expect(response).toEqual({
20
- content: {
21
- $type: "Block.Document",
22
- children: { $type: "Block.Heading", children: "Test Heading" },
23
- },
24
- });
25
- });
26
-
27
- test("Block.Text with children", () => {
28
- const text = Block.Text({ children: "Test text content" });
29
- expect(text.$type).toBe("Block.Text");
30
-
31
- const response: BlockResponse = {
32
- content: Block.Document({ children: text }),
33
- };
34
- expect(response).toEqual({
35
- content: {
36
- $type: "Block.Document",
37
- children: { $type: "Block.Text", children: "Test text content" },
38
- },
39
- });
40
- });
41
-
42
- test("Block.Heading with additional properties", () => {
43
- const heading = Block.Heading({
44
- children: "Styled Heading",
45
- fontSize: "md",
46
- fontWeight: "600",
47
- level: "2",
48
- });
49
-
50
- const response: BlockResponse = {
51
- content: Block.Document({ children: heading }),
52
- };
53
- expect(response).toEqual({
54
- content: {
55
- $type: "Block.Document",
56
- children: {
57
- $type: "Block.Heading",
58
- children: "Styled Heading",
59
- fontSize: "md",
60
- fontWeight: "600",
61
- level: "2",
62
- },
63
- },
64
- });
65
- });
66
-
67
- test("Block.Group with children array", () => {
68
- const group = Block.Group({
69
- children: [
70
- Block.Text({ children: "First item" }),
71
- Block.Text({ children: "Second item" }),
72
- ],
73
- flexDirection: "column",
74
- gap: "16",
75
- });
76
-
77
- const response: BlockResponse = {
78
- content: Block.Document({ children: group }),
79
- };
80
- expect(response).toEqual({
81
- content: {
82
- $type: "Block.Document",
83
- children: {
84
- $type: "Block.Group",
85
- children: [
86
- { $type: "Block.Text", children: "First item" },
87
- { $type: "Block.Text", children: "Second item" },
88
- ],
89
- flexDirection: "column",
90
- gap: "16",
91
- },
92
- },
93
- });
94
- });
95
-
96
- test("Block.Document", () => {
97
- const doc = Block.Document({
98
- children: [
99
- Block.Heading({ children: "Title", level: "2" }),
100
- Block.Text({ children: "Description" }),
101
- ],
102
- });
103
-
104
- const response: BlockResponse = { content: doc };
105
- expect(response).toEqual({
106
- content: {
107
- $type: "Block.Document",
108
- children: [
109
- { $type: "Block.Heading", children: "Title", level: "2" },
110
- { $type: "Block.Text", children: "Description" },
111
- ],
112
- },
113
- });
114
- });
115
- });