render.test.tsx (4641B)
1 import { Token } from '@/lib/markup/token' 2 import { render } from './render' 3 4 describe('Render', () => { 5 it('should render everything', () => { 6 const tokens: Token[] = [{ 7 key: 'paragraph', children: [{ 8 key: 'text', text: 'Hello, World!', 9 }], 10 }, { 11 key: 'horizontal-rule', 12 }, { 13 key: 'list', listType: 'unordered', children: [{ 14 key: 'list-item', children: [{ 15 key: 'text', children: [{ 16 key: 'text', text: 'This is a test.', 17 }], 18 }], 19 }, { 20 key: 'list-item', children: [{ 21 key: 'text', children: [{ 22 key: 'text', text: 'This is a test.', 23 }], 24 }, { 25 key: 'text', children: [{ 26 key: 'text', text: 'Multiple lines.', 27 }], 28 }], 29 }], 30 }, { 31 key: 'horizontal-rule', 32 }, { 33 key: 'list', listType: 'ordered', children: [{ 34 key: 'list-item', children: [{ 35 key: 'text', children: [{ 36 key: 'text', text: 'This is a test.', 37 }], 38 }], 39 }, { 40 key: 'list-item', children: [{ 41 key: 'text', children: [{ 42 key: 'text', text: 'This is a test.', 43 }], 44 }], 45 }], 46 }, { 47 key: 'horizontal-rule', 48 }, { 49 key: 'heading', level: 1, children: [{ 50 key: 'text', text: 'Hello, World!', 51 }], 52 }, { 53 key: 'heading', level: 2, children: [{ 54 key: 'text', text: 'This is a test.', 55 }], 56 }, { 57 key: 'horizontal-rule', 58 }, { 59 key: 'blockquote', children: [{ 60 key: 'paragraph', children: [{ 61 key: 'text', text: 'This is a test.', 62 }], 63 }], 64 }] 65 66 expect(render(tokens)).toMatchSnapshot() 67 }) 68 69 it('mixed list should be ok', () => { 70 const tokens: Token[] = [ 71 { 72 "key": "list", 73 "listType": "unordered", 74 "children": [ 75 { 76 "key": "list-item", 77 "children": [ 78 { 79 "key": "text", 80 "children": [ 81 { 82 "key": "text", 83 "text": "List Item 1" 84 } 85 ] 86 }, 87 { 88 "key": "text", 89 "children": [ 90 { 91 "key": "text", 92 "text": "List Item 2" 93 } 94 ] 95 } 96 ] 97 }, 98 { 99 "key": "list-item", 100 "children": [ 101 { 102 "key": "text", 103 "children": [ 104 { 105 "key": "text", 106 "text": "List Item" 107 } 108 ] 109 } 110 ] 111 }, 112 { 113 "key": "list-item", 114 "children": [ 115 { 116 "key": "text", 117 "children": [ 118 { 119 "key": "text", 120 "text": "List Item" 121 } 122 ] 123 }, 124 { 125 "key": "list", 126 "listType": "ordered", 127 "children": [ 128 { 129 "key": "list-item", 130 "children": [ 131 { 132 "key": "text", 133 "children": [ 134 { 135 "key": "text", 136 "text": "List Item" 137 } 138 ] 139 } 140 ] 141 }, 142 { 143 "key": "list-item", 144 "children": [ 145 { 146 "key": "text", 147 "children": [ 148 { 149 "key": "text", 150 "text": "List Item" 151 } 152 ] 153 } 154 ] 155 }, 156 { 157 "key": "list-item", 158 "children": [ 159 { 160 "key": "text", 161 "children": [ 162 { 163 "key": "text", 164 "text": "List Item" 165 } 166 ] 167 } 168 ] 169 } 170 ] 171 } 172 ] 173 } 174 ] 175 } 176 ] 177 178 expect(render(tokens)).toMatchSnapshot() 179 }) 180 }) 181 182 export {}