|
6 | 6 | MockParagraphNull, |
7 | 7 | } from '../../mockData/blocks.paragraph' |
8 | 8 | import { MockHeadingOne, MockHeadingTwo, MockHeadingThree } from '../../mockData/blocks.headings' |
| 9 | +import { MockTodoUnchecked, MockTodoChecked } from '../../mockData/blocks.todo' |
| 10 | +import { MockToggle } from '../../mockData/blocks.toggle' |
| 11 | +import { MockChildPage } from '../../mockData/blocks.child-page' |
9 | 12 | import { defaultAnnotations, defaultPluginConfigRes } from '../../mockData/defaults' |
10 | 13 |
|
11 | 14 | describe('Convert blocks', () => { |
@@ -107,5 +110,59 @@ describe('Convert blocks', () => { |
107 | 110 |
|
108 | 111 | expect(fn).toBe('<h4><span class=gs-undefined>Heading three</span></h4>') |
109 | 112 | }) |
| 113 | + |
| 114 | + it('should return an unchecked todo item', () => { |
| 115 | + const todoItemUnchecked = [MockTodoUnchecked] |
| 116 | + |
| 117 | + const fn = convertBlockToHTML(todoItemUnchecked, defaultPluginConfigRes) |
| 118 | + |
| 119 | + expect(fn).toBe( |
| 120 | + '<div class="gs-todo"><label for="657e68c6-1b09-478f-9912-c647e17077b8"><input type="checkbox" id="657e68c6-1b09-478f-9912-c647e17077b8" /> <span class=gs-undefined>Lorem Ipsum Lorem Ipsum</span></label></div>' |
| 121 | + ) |
| 122 | + }) |
| 123 | + |
| 124 | + it('should return a checked todo item', () => { |
| 125 | + const todoItemChecked = [MockTodoChecked] |
| 126 | + |
| 127 | + const fn = convertBlockToHTML(todoItemChecked, defaultPluginConfigRes) |
| 128 | + |
| 129 | + expect(fn).toBe( |
| 130 | + '<div class="gs-todo"><label for="657e68c6-1b09-478f-9912-c647e17077b8"><input type="checkbox" id="657e68c6-1b09-478f-9912-c647e17077b8" checked /> <span class=gs-undefined>Lorem Ipsum Lorem Ipsum</span></label></div>' |
| 131 | + ) |
| 132 | + }) |
| 133 | + |
| 134 | + it('should return a toggle', () => { |
| 135 | + const toggle = [MockToggle] |
| 136 | + |
| 137 | + const fn = convertBlockToHTML(toggle, defaultPluginConfigRes) |
| 138 | + |
| 139 | + expect(fn).toBe( |
| 140 | + '<details class="gs-toggle"><summary><span class=gs-undefined>Lorem Ipsum Lorem Ipsum</span></summary>It\'s a toggle!</details>' |
| 141 | + ) |
| 142 | + }) |
| 143 | + |
| 144 | + it('should return a child page', () => { |
| 145 | + const childPage = [MockChildPage] |
| 146 | + |
| 147 | + const fn = convertBlockToHTML(childPage, defaultPluginConfigRes) |
| 148 | + |
| 149 | + expect(fn).toBe('<p class="gs-child-page">This is a child page</p>') |
| 150 | + }) |
| 151 | + |
| 152 | + it('should return empty if block is not supported', () => { |
| 153 | + const noSupported = [] |
| 154 | + |
| 155 | + const fn = convertBlockToHTML(noSupported, defaultPluginConfigRes) |
| 156 | + |
| 157 | + expect(fn).toBe('') |
| 158 | + }) |
| 159 | + |
| 160 | + it('should return a message if block is not supported', () => { |
| 161 | + const noSupported = [{}] |
| 162 | + |
| 163 | + const fn = convertBlockToHTML(noSupported, { get: () => 'unsupported' }) |
| 164 | + |
| 165 | + expect(fn).toBe('❌ Unsupported block (undefined)') |
| 166 | + }) |
110 | 167 | }) |
111 | 168 | }) |
0 commit comments