Skip to content

Commit 1d5282c

Browse files
committed
Add specs
1 parent c47e474 commit 1d5282c

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/auto-check-element.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ function makeAbortController() {
219219
}
220220

221221
async function fetchWithNetworkEvents(el: Element, url: string, options: RequestInit): Promise<Response> {
222+
if (options.method === 'GET') {
223+
delete options.body
224+
}
222225
try {
223226
const response = await fetch(url, options)
224227
el.dispatchEvent(new Event('load'))

test/auto-check.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,35 @@ describe('auto-check element', function () {
114114
})
115115
})
116116

117+
describe('using HTTP GET', function () {
118+
let checker
119+
let input
120+
121+
beforeEach(function () {
122+
const container = document.createElement('div')
123+
container.innerHTML = `
124+
<auto-check src="/success" http-method="GET" required>
125+
<input>
126+
</auto-check>`
127+
document.body.append(container)
128+
129+
checker = document.querySelector('auto-check')
130+
input = checker.querySelector('input')
131+
})
132+
133+
afterEach(function () {
134+
document.body.innerHTML = ''
135+
checker = null
136+
input = null
137+
})
138+
139+
it('validates input with successful server response with GET', async function () {
140+
triggerInput(input, 'hub')
141+
await once(input, 'auto-check-complete')
142+
assert.isTrue(input.checkValidity())
143+
})
144+
})
145+
117146
describe('network lifecycle events', function () {
118147
let checker
119148
let input

web-test-runner.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
middleware: [
2020
async ({request, response}, next) => {
2121
const {method, path} = request
22-
if (method === 'POST') {
22+
if (method === 'POST' || method === 'GET') {
2323
if (path.startsWith('/fail')) {
2424
response.status = 422
2525
// eslint-disable-next-line i18n-text/no-en

0 commit comments

Comments
 (0)