-
Notifications
You must be signed in to change notification settings - Fork 15
/
dynamic.cy.js
31 lines (29 loc) · 1.07 KB
/
dynamic.cy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { test, html } from './utils'
test('[x-target] can be dynamic',
html`<form x-data="{ target: 'replace' }" x-target:dynamic="target" id="replace" method="post" action="/tests"><button></button></form>`,
({ intercept, get, wait }) => {
intercept('POST', '/tests', {
statusCode: 200,
body: '<h1 id="title">Success</h1><div id="replace">Replaced</div>'
}).as('response')
get('button').click()
wait('@response').then(() => {
get('#title').should('not.exist')
get('#replace').should('have.text', 'Replaced')
})
}
)
test('[x-merge] can be dynamic',
html`<form x-data="{ strategy: 'replace' }" x-target x-merge:dynamic="strategy" id="replace" method="post"><button></button></form>`,
({ intercept, get, wait }) => {
intercept('POST', '/tests', {
statusCode: 200,
body: '<h1 id="title">Success</h1><div id="replace">Replaced</div>'
}).as('response')
get('button').click()
wait('@response').then(() => {
get('#title').should('not.exist')
get('#replace').should('have.text', 'Replaced')
})
}
)