-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add invalid range request test (#175)
* feature: add invalid range request test * improve range request handling for invalid range * coverage
- Loading branch information
Showing
4 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/test-integration/test/PreviewProcessRangeRequestInvalid.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { expect, test } from '@jest/globals' | ||
import getPort from 'get-port' | ||
import { createPreviewProcess } from '../src/parts/CreatePreviewProcess/CreatePreviewProcess.js' | ||
import { get } from '../src/parts/Get/Get.js' | ||
import { getRoot } from '../src/parts/GetRoot/GetRoot.js' | ||
|
||
test('preview process - handles invalid range request', async () => { | ||
const previewProcess = createPreviewProcess() | ||
const id = 1 | ||
const port = await getPort() | ||
const root = getRoot() | ||
|
||
await previewProcess.invoke('WebViewServer.create', id) | ||
await previewProcess.invoke('WebViewServer.setHandler', id, '', root, '', '') | ||
await previewProcess.invoke('WebViewServer.start', id, port) | ||
|
||
const response = await get(`http://localhost:${port}/package.json`, { | ||
headers: { | ||
Range: 'bytes=invalid-range', | ||
}, | ||
}) | ||
|
||
expect(response.status).toBe(400) // Bad Request | ||
expect(await response.text()).toBe('Invalid Range') | ||
|
||
previewProcess[Symbol.dispose]() | ||
}) |