|
1 | 1 | import { render } from '@testing-library/svelte'
|
2 |
| -import { VERSION as SVELTE_VERSION } from 'svelte/compiler' |
3 | 2 | import { describe, expect, test } from 'vitest'
|
4 | 3 |
|
5 | 4 | import Comp from './fixtures/Comp.svelte'
|
| 5 | +import { IS_SVELTE_5 } from './utils.js' |
6 | 6 |
|
7 | 7 | describe('render', () => {
|
8 | 8 | const props = { name: 'World' }
|
@@ -65,24 +65,21 @@ describe('render', () => {
|
65 | 65 | expect(baseElement.firstChild).toBe(container)
|
66 | 66 | })
|
67 | 67 |
|
68 |
| - test.runIf(SVELTE_VERSION < '5')( |
69 |
| - 'should accept anchor option in Svelte v4', |
70 |
| - () => { |
71 |
| - const baseElement = document.body |
72 |
| - const target = document.createElement('section') |
73 |
| - const anchor = document.createElement('div') |
74 |
| - baseElement.appendChild(target) |
75 |
| - target.appendChild(anchor) |
76 |
| - |
77 |
| - const { getByTestId } = render( |
78 |
| - Comp, |
79 |
| - { props, target, anchor }, |
80 |
| - { baseElement } |
81 |
| - ) |
82 |
| - const firstElement = getByTestId('test') |
83 |
| - |
84 |
| - expect(target.firstChild).toBe(firstElement) |
85 |
| - expect(target.lastChild).toBe(anchor) |
86 |
| - } |
87 |
| - ) |
| 68 | + test.skipIf(IS_SVELTE_5)('should accept anchor option in Svelte v4', () => { |
| 69 | + const baseElement = document.body |
| 70 | + const target = document.createElement('section') |
| 71 | + const anchor = document.createElement('div') |
| 72 | + baseElement.appendChild(target) |
| 73 | + target.appendChild(anchor) |
| 74 | + |
| 75 | + const { getByTestId } = render( |
| 76 | + Comp, |
| 77 | + { props, target, anchor }, |
| 78 | + { baseElement } |
| 79 | + ) |
| 80 | + const firstElement = getByTestId('test') |
| 81 | + |
| 82 | + expect(target.firstChild).toBe(firstElement) |
| 83 | + expect(target.lastChild).toBe(anchor) |
| 84 | + }) |
88 | 85 | })
|
0 commit comments