| 416 | |
| 417 | describe('codegen', () => { |
| 418 | function assertSharedCodegen( |
| 419 | node: IfConditionalExpression, |
| 420 | depth: number = 0, |
| 421 | hasElse: boolean = false, |
| 422 | ) { |
| 423 | expect(node).toMatchObject({ |
| 424 | type: NodeTypes.JS_CONDITIONAL_EXPRESSION, |
| 425 | test: { |
| 426 | content: `ok`, |
| 427 | }, |
| 428 | consequent: { |
| 429 | type: NodeTypes.VNODE_CALL, |
| 430 | isBlock: true, |
| 431 | }, |
| 432 | alternate: |
| 433 | depth < 1 |
| 434 | ? hasElse |
| 435 | ? { |
| 436 | type: NodeTypes.VNODE_CALL, |
| 437 | isBlock: true, |
| 438 | } |
| 439 | : { |
| 440 | type: NodeTypes.JS_CALL_EXPRESSION, |
| 441 | callee: CREATE_COMMENT, |
| 442 | } |
| 443 | : { |
| 444 | type: NodeTypes.JS_CONDITIONAL_EXPRESSION, |
| 445 | test: { |
| 446 | content: `orNot`, |
| 447 | }, |
| 448 | consequent: { |
| 449 | type: NodeTypes.VNODE_CALL, |
| 450 | isBlock: true, |
| 451 | }, |
| 452 | alternate: hasElse |
| 453 | ? { |
| 454 | type: NodeTypes.VNODE_CALL, |
| 455 | isBlock: true, |
| 456 | } |
| 457 | : { |
| 458 | type: NodeTypes.JS_CALL_EXPRESSION, |
| 459 | callee: CREATE_COMMENT, |
| 460 | }, |
| 461 | }, |
| 462 | }) |
| 463 | } |
| 464 | |
| 465 | test('basic v-if', () => { |
| 466 | const { |