|
| 1 | +import { Test, TestingModule } from '@nestjs/testing'; |
| 2 | +import { PageService } from './page.service'; |
| 3 | +import { PageRepository } from './page.repository'; |
| 4 | +import { NodeRepository } from '../node/node.repository'; |
| 5 | +import { Page } from './page.entity'; |
| 6 | +import { Node } from '../node/node.entity'; |
| 7 | +import { CreatePageDto } from './dtos/createPage.dto'; |
| 8 | +import { UpdatePageDto } from './dtos/updatePage.dto'; |
| 9 | +import { PageNotFoundException } from '../exception/page.exception'; |
| 10 | +import { EdgeService } from 'src/edge/edge.service'; |
| 11 | +import { NodeService } from 'src/node/node.service'; |
| 12 | +import { YjsService } from './yjs.service'; |
| 13 | + |
| 14 | +describe('PageService', () => { |
| 15 | + const dummyNovelData = { |
| 16 | + type: 'doc', |
| 17 | + content: [ |
| 18 | + { |
| 19 | + type: 'paragraph', |
| 20 | + content: [ |
| 21 | + { |
| 22 | + type: 'text', |
| 23 | + text: 'asdf', |
| 24 | + }, |
| 25 | + ], |
| 26 | + }, |
| 27 | + { |
| 28 | + type: 'taskList', |
| 29 | + content: [ |
| 30 | + { |
| 31 | + type: 'taskItem', |
| 32 | + attrs: { |
| 33 | + checked: false, |
| 34 | + }, |
| 35 | + content: [ |
| 36 | + { |
| 37 | + type: 'paragraph', |
| 38 | + content: [ |
| 39 | + { |
| 40 | + type: 'text', |
| 41 | + text: '아녕하세요', |
| 42 | + }, |
| 43 | + ], |
| 44 | + }, |
| 45 | + ], |
| 46 | + }, |
| 47 | + { |
| 48 | + type: 'taskItem', |
| 49 | + attrs: { |
| 50 | + checked: false, |
| 51 | + }, |
| 52 | + content: [ |
| 53 | + { |
| 54 | + type: 'paragraph', |
| 55 | + content: [ |
| 56 | + { |
| 57 | + type: 'text', |
| 58 | + text: '하하', |
| 59 | + }, |
| 60 | + ], |
| 61 | + }, |
| 62 | + ], |
| 63 | + }, |
| 64 | + ], |
| 65 | + }, |
| 66 | + { |
| 67 | + type: 'heading', |
| 68 | + attrs: { |
| 69 | + level: 1, |
| 70 | + }, |
| 71 | + content: [ |
| 72 | + { |
| 73 | + type: 'text', |
| 74 | + text: '제목임', |
| 75 | + }, |
| 76 | + ], |
| 77 | + }, |
| 78 | + { |
| 79 | + type: 'heading', |
| 80 | + attrs: { |
| 81 | + level: 2, |
| 82 | + }, |
| 83 | + content: [ |
| 84 | + { |
| 85 | + type: 'text', |
| 86 | + text: '네목임', |
| 87 | + }, |
| 88 | + ], |
| 89 | + }, |
| 90 | + { |
| 91 | + type: 'heading', |
| 92 | + attrs: { |
| 93 | + level: 3, |
| 94 | + }, |
| 95 | + content: [ |
| 96 | + { |
| 97 | + type: 'text', |
| 98 | + text: '세목임', |
| 99 | + }, |
| 100 | + ], |
| 101 | + }, |
| 102 | + { |
| 103 | + type: 'bulletList', |
| 104 | + attrs: { |
| 105 | + tight: true, |
| 106 | + }, |
| 107 | + content: [ |
| 108 | + { |
| 109 | + type: 'listItem', |
| 110 | + content: [ |
| 111 | + { |
| 112 | + type: 'paragraph', |
| 113 | + content: [ |
| 114 | + { |
| 115 | + type: 'text', |
| 116 | + text: 'gfsd', |
| 117 | + }, |
| 118 | + ], |
| 119 | + }, |
| 120 | + ], |
| 121 | + }, |
| 122 | + { |
| 123 | + type: 'listItem', |
| 124 | + content: [ |
| 125 | + { |
| 126 | + type: 'paragraph', |
| 127 | + content: [ |
| 128 | + { |
| 129 | + type: 'text', |
| 130 | + text: 'gfsd', |
| 131 | + }, |
| 132 | + ], |
| 133 | + }, |
| 134 | + ], |
| 135 | + }, |
| 136 | + { |
| 137 | + type: 'listItem', |
| 138 | + content: [ |
| 139 | + { |
| 140 | + type: 'paragraph', |
| 141 | + content: [ |
| 142 | + { |
| 143 | + type: 'text', |
| 144 | + text: 'hgfd', |
| 145 | + }, |
| 146 | + ], |
| 147 | + }, |
| 148 | + ], |
| 149 | + }, |
| 150 | + ], |
| 151 | + }, |
| 152 | + { |
| 153 | + type: 'orderedList', |
| 154 | + attrs: { |
| 155 | + tight: true, |
| 156 | + start: 1, |
| 157 | + }, |
| 158 | + content: [ |
| 159 | + { |
| 160 | + type: 'listItem', |
| 161 | + content: [ |
| 162 | + { |
| 163 | + type: 'paragraph', |
| 164 | + content: [ |
| 165 | + { |
| 166 | + type: 'text', |
| 167 | + text: 'gsf', |
| 168 | + }, |
| 169 | + ], |
| 170 | + }, |
| 171 | + ], |
| 172 | + }, |
| 173 | + { |
| 174 | + type: 'listItem', |
| 175 | + content: [ |
| 176 | + { |
| 177 | + type: 'paragraph', |
| 178 | + content: [ |
| 179 | + { |
| 180 | + type: 'text', |
| 181 | + text: 'hgfddf', |
| 182 | + }, |
| 183 | + ], |
| 184 | + }, |
| 185 | + ], |
| 186 | + }, |
| 187 | + { |
| 188 | + type: 'listItem', |
| 189 | + content: [ |
| 190 | + { |
| 191 | + type: 'paragraph', |
| 192 | + content: [ |
| 193 | + { |
| 194 | + type: 'text', |
| 195 | + text: 'fd', |
| 196 | + }, |
| 197 | + ], |
| 198 | + }, |
| 199 | + ], |
| 200 | + }, |
| 201 | + ], |
| 202 | + }, |
| 203 | + { |
| 204 | + type: 'codeBlock', |
| 205 | + attrs: { |
| 206 | + language: null, |
| 207 | + }, |
| 208 | + content: [ |
| 209 | + { |
| 210 | + type: 'text', |
| 211 | + text: 'codingdi', |
| 212 | + }, |
| 213 | + ], |
| 214 | + }, |
| 215 | + { |
| 216 | + type: 'blockquote', |
| 217 | + content: [ |
| 218 | + { |
| 219 | + type: 'paragraph', |
| 220 | + content: [ |
| 221 | + { |
| 222 | + type: 'text', |
| 223 | + text: 'dlsdydla', |
| 224 | + }, |
| 225 | + ], |
| 226 | + }, |
| 227 | + ], |
| 228 | + }, |
| 229 | + { |
| 230 | + type: 'youtube', |
| 231 | + attrs: { |
| 232 | + src: 'https://www.youtube.com/watch?v=_2p2pFUoS5c', |
| 233 | + start: 0, |
| 234 | + width: 640, |
| 235 | + height: 480, |
| 236 | + }, |
| 237 | + }, |
| 238 | + { |
| 239 | + type: 'paragraph', |
| 240 | + }, |
| 241 | + { |
| 242 | + type: 'twitter', |
| 243 | + attrs: { |
| 244 | + src: 'https://x.com/withyou3542', |
| 245 | + }, |
| 246 | + }, |
| 247 | + { |
| 248 | + type: 'paragraph', |
| 249 | + }, |
| 250 | + { |
| 251 | + type: 'paragraph', |
| 252 | + }, |
| 253 | + ], |
| 254 | + }; |
| 255 | + let yjsService: YjsService; |
| 256 | + let pageService: PageService; |
| 257 | + let nodeService: NodeService; |
| 258 | + let edgeService: EdgeService; |
| 259 | + |
| 260 | + beforeEach(async () => { |
| 261 | + const module: TestingModule = await Test.createTestingModule({ |
| 262 | + providers: [ |
| 263 | + YjsService, |
| 264 | + { |
| 265 | + provide: PageService, |
| 266 | + useValue: {}, |
| 267 | + }, |
| 268 | + { |
| 269 | + provide: PageService, |
| 270 | + useValue: {}, |
| 271 | + }, |
| 272 | + { |
| 273 | + provide: NodeService, |
| 274 | + useValue: {}, |
| 275 | + }, |
| 276 | + { |
| 277 | + provide: EdgeService, |
| 278 | + useValue: {}, |
| 279 | + }, |
| 280 | + ], |
| 281 | + }).compile(); |
| 282 | + |
| 283 | + yjsService = module.get<YjsService>(YjsService); |
| 284 | + pageService = module.get<PageService>(PageService); |
| 285 | + nodeService = module.get<NodeService>(NodeService); |
| 286 | + edgeService = module.get<EdgeService>(EdgeService); |
| 287 | + }); |
| 288 | + |
| 289 | + it('서비스 클래스가 정상적으로 인스턴스화된다.', () => { |
| 290 | + expect(yjsService).toBeDefined(); |
| 291 | + expect(pageService).toBeDefined(); |
| 292 | + expect(nodeService).toBeDefined(); |
| 293 | + expect(edgeService).toBeDefined(); |
| 294 | + }); |
| 295 | + |
| 296 | + it('모든 페이지 목록을 조회할 수 있다.', async () => {}); |
| 297 | + |
| 298 | + describe('createPage', () => { |
| 299 | + it('페이지를 성공적으로 생성한다.', async () => { |
| 300 | + }); |
| 301 | + }); |
| 302 | +}); |
0 commit comments